code-ruby 2.0.2 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/VERSION +1 -1
- data/lib/code/format.rb +4 -2
- data/lib/code/parser.rb +1113 -6
- data/lib/code-ruby.rb +0 -1
- data/spec/code/node/call_spec.rb +1 -1
- data/spec/code/parser/boolean_spec.rb +1 -1
- data/spec/code/parser/chained_call_spec.rb +1 -1
- data/spec/code/parser/dictionary_spec.rb +1 -1
- data/spec/code/parser/function_spec.rb +1 -1
- data/spec/code/parser/group_spec.rb +1 -1
- data/spec/code/parser/if_modifier_spec.rb +1 -1
- data/spec/code/parser/list_spec.rb +1 -1
- data/spec/code/parser/number_spec.rb +1 -1
- data/spec/code/parser/string_spec.rb +1 -1
- data/spec/code_spec.rb +1 -1
- metadata +1 -42
- data/lib/code/parser/addition.rb +0 -23
- data/lib/code/parser/and_operator.rb +0 -19
- data/lib/code/parser/bitwise_and.rb +0 -23
- data/lib/code/parser/bitwise_or.rb +0 -23
- data/lib/code/parser/boolean.rb +0 -23
- data/lib/code/parser/call.rb +0 -165
- data/lib/code/parser/chained_call.rb +0 -31
- data/lib/code/parser/class.rb +0 -15
- data/lib/code/parser/code.rb +0 -27
- data/lib/code/parser/dictionary.rb +0 -76
- data/lib/code/parser/equal.rb +0 -67
- data/lib/code/parser/equality.rb +0 -42
- data/lib/code/parser/function.rb +0 -135
- data/lib/code/parser/greater.rb +0 -32
- data/lib/code/parser/group.rb +0 -58
- data/lib/code/parser/if.rb +0 -101
- data/lib/code/parser/if_modifier.rb +0 -39
- data/lib/code/parser/label_name.rb +0 -14
- data/lib/code/parser/left_operation.rb +0 -44
- data/lib/code/parser/list.rb +0 -47
- data/lib/code/parser/multiplication.rb +0 -39
- data/lib/code/parser/name.rb +0 -188
- data/lib/code/parser/negation.rb +0 -32
- data/lib/code/parser/not_keyword.rb +0 -29
- data/lib/code/parser/nothing.rb +0 -19
- data/lib/code/parser/number.rb +0 -156
- data/lib/code/parser/or_keyword.rb +0 -27
- data/lib/code/parser/or_operator.rb +0 -19
- data/lib/code/parser/power.rb +0 -19
- data/lib/code/parser/range.rb +0 -19
- data/lib/code/parser/rescue.rb +0 -19
- data/lib/code/parser/right_operation.rb +0 -44
- data/lib/code/parser/shift.rb +0 -23
- data/lib/code/parser/splat.rb +0 -33
- data/lib/code/parser/square_bracket.rb +0 -44
- data/lib/code/parser/statement.rb +0 -11
- data/lib/code/parser/string.rb +0 -85
- data/lib/code/parser/ternary.rb +0 -45
- data/lib/code/parser/unary_minus.rb +0 -33
- data/lib/code/parser/while.rb +0 -81
- data/lib/code/parser/whitespace.rb +0 -51
data/lib/code/parser/string.rb
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class Code
|
|
4
|
-
class Parser
|
|
5
|
-
class String < Language
|
|
6
|
-
def code
|
|
7
|
-
Code
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def name
|
|
11
|
-
Name
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def label_name
|
|
15
|
-
LabelName
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def single_quote
|
|
19
|
-
str("'")
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def double_quote
|
|
23
|
-
str('"')
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def backslash
|
|
27
|
-
str('\\')
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def opening_curly_bracket
|
|
31
|
-
str("{")
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def closing_curly_bracket
|
|
35
|
-
str("}")
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def colon
|
|
39
|
-
str(":")
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def code_part
|
|
43
|
-
opening_curly_bracket.ignore << code <<
|
|
44
|
-
closing_curly_bracket.maybe.ignore
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def single_quoted_text_part
|
|
48
|
-
(
|
|
49
|
-
(backslash.ignore << opening_curly_bracket) |
|
|
50
|
-
(backslash.ignore << single_quote) |
|
|
51
|
-
(single_quote.absent << opening_curly_bracket.absent << any)
|
|
52
|
-
).repeat(1)
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
def double_quoted_text_part
|
|
56
|
-
(
|
|
57
|
-
(backslash.ignore << opening_curly_bracket) |
|
|
58
|
-
(backslash.ignore << double_quote) |
|
|
59
|
-
(double_quote.absent << opening_curly_bracket.absent << any)
|
|
60
|
-
).repeat(1)
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
def single_quoted_string
|
|
64
|
-
single_quote.ignore << (
|
|
65
|
-
code_part.aka(:code) | single_quoted_text_part.aka(:text)
|
|
66
|
-
).repeat << single_quote.ignore.maybe
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
def double_quoted_string
|
|
70
|
-
double_quote.ignore << (
|
|
71
|
-
code_part.aka(:code) | double_quoted_text_part.aka(:text)
|
|
72
|
-
).repeat << double_quote.ignore.maybe
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
def symbol
|
|
76
|
-
(colon.ignore << label_name).aka(:text).repeat(1, 1)
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
def root
|
|
80
|
-
(single_quoted_string | double_quoted_string | symbol).aka(:string) |
|
|
81
|
-
Number
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
end
|
data/lib/code/parser/ternary.rb
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class Code
|
|
4
|
-
class Parser
|
|
5
|
-
class Ternary < Language
|
|
6
|
-
def statement
|
|
7
|
-
Range
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def ternary
|
|
11
|
-
Ternary
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def whitespace
|
|
15
|
-
Whitespace
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def whitespace?
|
|
19
|
-
whitespace.maybe
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def question_mark
|
|
23
|
-
str("?")
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def colon
|
|
27
|
-
str(":")
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def root
|
|
31
|
-
(
|
|
32
|
-
statement.aka(:left) << (
|
|
33
|
-
whitespace? << question_mark << whitespace? <<
|
|
34
|
-
ternary.aka(:middle) <<
|
|
35
|
-
(whitespace? << colon << whitespace? << ternary.aka(:right)).maybe
|
|
36
|
-
).maybe
|
|
37
|
-
)
|
|
38
|
-
.aka(:ternary)
|
|
39
|
-
.then do |output|
|
|
40
|
-
output[:ternary][:middle] ? output : output[:ternary][:left]
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class Code
|
|
4
|
-
class Parser
|
|
5
|
-
class UnaryMinus < Language
|
|
6
|
-
def unary_minus
|
|
7
|
-
UnaryMinus
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def whitespace
|
|
11
|
-
Whitespace
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def whitespace?
|
|
15
|
-
whitespace.maybe
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def minus
|
|
19
|
-
str("-")
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def operator
|
|
23
|
-
minus
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def root
|
|
27
|
-
(operator.aka(:operator) << whitespace? << unary_minus.aka(:right)).aka(
|
|
28
|
-
:unary_minus
|
|
29
|
-
) | Power
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
data/lib/code/parser/while.rb
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class Code
|
|
4
|
-
class Parser
|
|
5
|
-
class While < Language
|
|
6
|
-
def statement
|
|
7
|
-
If
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def whitespace
|
|
11
|
-
Whitespace
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def whitespace?
|
|
15
|
-
whitespace.maybe
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def code
|
|
19
|
-
Code
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def separator
|
|
23
|
-
Name.new.separator
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def while_keyword
|
|
27
|
-
str("while") << separator.present
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def until_keyword
|
|
31
|
-
str("until") << separator.present
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def end_keyword
|
|
35
|
-
str("end") << separator.present
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def do_keyword
|
|
39
|
-
str("do") << separator.present
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def begin_keyword
|
|
43
|
-
str("begin") << separator.present
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def loop_keyword
|
|
47
|
-
str("loop") << separator.present
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
def opening_curly_bracket
|
|
51
|
-
str("{")
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
def closing_curly_bracket
|
|
55
|
-
str("}")
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
def body
|
|
59
|
-
(
|
|
60
|
-
(begin_keyword | do_keyword).ignore << whitespace << code <<
|
|
61
|
-
(whitespace? << end_keyword).maybe.ignore
|
|
62
|
-
) |
|
|
63
|
-
(
|
|
64
|
-
opening_curly_bracket.ignore << whitespace? << code <<
|
|
65
|
-
(whitespace? << closing_curly_bracket).maybe.ignore
|
|
66
|
-
) | (code << (whitespace? << end_keyword).maybe.ignore)
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
def root
|
|
70
|
-
(
|
|
71
|
-
(
|
|
72
|
-
(
|
|
73
|
-
(while_keyword | until_keyword).aka(:operator) << whitespace <<
|
|
74
|
-
statement.aka(:statement)
|
|
75
|
-
) | (loop_keyword.aka(:operator) << whitespace)
|
|
76
|
-
) << body.aka(:body)
|
|
77
|
-
).aka(:while) | statement
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
end
|
|
81
|
-
end
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class Code
|
|
4
|
-
class Parser
|
|
5
|
-
class Whitespace < Language
|
|
6
|
-
def space
|
|
7
|
-
str(" ")
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def newline
|
|
11
|
-
str("\n") | str("\r")
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def hashtag
|
|
15
|
-
str("#")
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def slash
|
|
19
|
-
str("/")
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def asterisk
|
|
23
|
-
str("*")
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def hash_comment
|
|
27
|
-
hashtag << (newline.absent << any).repeat << newline.maybe
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def double_slash_comment
|
|
31
|
-
slash << slash << (newline.absent << any).repeat << newline.maybe
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def multi_line_comment
|
|
35
|
-
slash << asterisk << ((asterisk << slash).absent << any).repeat <<
|
|
36
|
-
asterisk.maybe << slash.maybe
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def without_newline
|
|
40
|
-
(space | multi_line_comment).repeat(1).ignore
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def root
|
|
44
|
-
(
|
|
45
|
-
space | newline | hash_comment | double_slash_comment |
|
|
46
|
-
multi_line_comment
|
|
47
|
-
).repeat(1).ignore | any.absent
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
end
|