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/name.rb
DELETED
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class Code
|
|
4
|
-
class Parser
|
|
5
|
-
class Name < Language
|
|
6
|
-
def space
|
|
7
|
-
str(" ")
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def newline
|
|
11
|
-
str("\n")
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def comma
|
|
15
|
-
str(",")
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def equal
|
|
19
|
-
str("=")
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def colon
|
|
23
|
-
str(":")
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def opening_curly_bracket
|
|
27
|
-
str("{")
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def closing_curly_bracket
|
|
31
|
-
str("}")
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def opening_square_bracket
|
|
35
|
-
str("[")
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def closing_square_bracket
|
|
39
|
-
str("]")
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def opening_parenthesis
|
|
43
|
-
str("(")
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def closing_parenthesis
|
|
47
|
-
str(")")
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
def single_quote
|
|
51
|
-
str("'")
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
def double_quote
|
|
55
|
-
str('"')
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
def dot
|
|
59
|
-
str(".")
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
def pipe
|
|
63
|
-
str("|")
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
def ampersand
|
|
67
|
-
str("&")
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
def lesser
|
|
71
|
-
str("<")
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
def greater
|
|
75
|
-
str(">")
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
def asterisk
|
|
79
|
-
str("*")
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
def do_keyword
|
|
83
|
-
str("do")
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
def begin_keyword
|
|
87
|
-
str("begin")
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
def end_keyword
|
|
91
|
-
str("end")
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
def elsif_keyword
|
|
95
|
-
str("elsif")
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
def else_keyword
|
|
99
|
-
str("else")
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
def while_keyword
|
|
103
|
-
str("while")
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
def until_keyword
|
|
107
|
-
str("until")
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
def if_keyword
|
|
111
|
-
str("if")
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
def unless_keyword
|
|
115
|
-
str("unless")
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
def elsunless_keyword
|
|
119
|
-
str("elsunless")
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
def true_keyword
|
|
123
|
-
str("true")
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
def false_keyword
|
|
127
|
-
str("false")
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
def nothing_keyword
|
|
131
|
-
str("nothing")
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
def exclamation_mark
|
|
135
|
-
str("!")
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
def question_mark
|
|
139
|
-
str("?")
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
def hashtag
|
|
143
|
-
str("#")
|
|
144
|
-
end
|
|
145
|
-
|
|
146
|
-
def special_name
|
|
147
|
-
str("...") | str("..") | str(".") | str("**") | str("*") | str("&")
|
|
148
|
-
end
|
|
149
|
-
|
|
150
|
-
def reserved_character
|
|
151
|
-
ampersand | equal | pipe | dot | colon | comma | space | newline |
|
|
152
|
-
opening_curly_bracket | closing_curly_bracket | opening_parenthesis |
|
|
153
|
-
closing_parenthesis | opening_square_bracket |
|
|
154
|
-
closing_square_bracket | single_quote | double_quote | lesser |
|
|
155
|
-
greater | asterisk | hashtag
|
|
156
|
-
end
|
|
157
|
-
|
|
158
|
-
def character
|
|
159
|
-
reserved_character.absent << any
|
|
160
|
-
end
|
|
161
|
-
|
|
162
|
-
def separator
|
|
163
|
-
reserved_character | any.absent
|
|
164
|
-
end
|
|
165
|
-
|
|
166
|
-
def special_characters
|
|
167
|
-
exclamation_mark | question_mark
|
|
168
|
-
end
|
|
169
|
-
|
|
170
|
-
def keyword
|
|
171
|
-
do_keyword | begin_keyword | end_keyword | while_keyword |
|
|
172
|
-
until_keyword | if_keyword | elsif_keyword | else_keyword |
|
|
173
|
-
unless_keyword | elsunless_keyword | true_keyword | false_keyword |
|
|
174
|
-
nothing_keyword
|
|
175
|
-
end
|
|
176
|
-
|
|
177
|
-
def root
|
|
178
|
-
(
|
|
179
|
-
(special_name << separator.ignore) |
|
|
180
|
-
(
|
|
181
|
-
(keyword << separator).absent << special_characters.absent <<
|
|
182
|
-
character.repeat(1)
|
|
183
|
-
)
|
|
184
|
-
)
|
|
185
|
-
end
|
|
186
|
-
end
|
|
187
|
-
end
|
|
188
|
-
end
|
data/lib/code/parser/negation.rb
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class Code
|
|
4
|
-
class Parser
|
|
5
|
-
class Negation < Language
|
|
6
|
-
def exclamation_mark
|
|
7
|
-
str("!")
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def tilde
|
|
11
|
-
str("~")
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def plus
|
|
15
|
-
str("+")
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def operator
|
|
19
|
-
exclamation_mark | tilde | plus
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def negation
|
|
23
|
-
Negation
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def root
|
|
27
|
-
(operator.aka(:operator) << negation.aka(:right)).aka(:negation) |
|
|
28
|
-
ChainedCall
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class Code
|
|
4
|
-
class Parser
|
|
5
|
-
class NotKeyword < Language
|
|
6
|
-
def not_class
|
|
7
|
-
NotKeyword
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def whitespace
|
|
11
|
-
Whitespace
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def separator
|
|
15
|
-
Name.new.separator
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def not_keyword
|
|
19
|
-
str("not") << separator.present
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def root
|
|
23
|
-
(not_keyword.aka(:operator) << whitespace << not_class.aka(:right)).aka(
|
|
24
|
-
:not
|
|
25
|
-
) | Equal
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
data/lib/code/parser/nothing.rb
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class Code
|
|
4
|
-
class Parser
|
|
5
|
-
class Nothing < Language
|
|
6
|
-
def separator
|
|
7
|
-
Name.new.separator
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def nothing_keyword
|
|
11
|
-
str("nothing") << separator.present
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def root
|
|
15
|
-
nothing_keyword.aka(:nothing) | Group
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
data/lib/code/parser/number.rb
DELETED
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class Code
|
|
4
|
-
class Parser
|
|
5
|
-
class Number < Language
|
|
6
|
-
def number
|
|
7
|
-
Number
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def zero
|
|
11
|
-
str("0")
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def one
|
|
15
|
-
str("1")
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def two
|
|
19
|
-
str("2")
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def three
|
|
23
|
-
str("3")
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def four
|
|
27
|
-
str("4")
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def five
|
|
31
|
-
str("5")
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def six
|
|
35
|
-
str("6")
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def seven
|
|
39
|
-
str("7")
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def eight
|
|
43
|
-
str("8")
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def nine
|
|
47
|
-
str("9")
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
def dot
|
|
51
|
-
str(".")
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
def a
|
|
55
|
-
str("a") | str("A")
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
def b
|
|
59
|
-
str("b") | str("B")
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
def c
|
|
63
|
-
str("c") | str("C")
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
def d
|
|
67
|
-
str("d") | str("D")
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
def e
|
|
71
|
-
str("e") | str("E")
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
def f
|
|
75
|
-
str("f") | str("F")
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
def o
|
|
79
|
-
str("o") | str("O")
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
def x
|
|
83
|
-
str("x") | str("X")
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
def underscore
|
|
87
|
-
str("_")
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
def base_16_digit
|
|
91
|
-
zero | one | two | three | four | five | six | seven | eight | nine |
|
|
92
|
-
a | b | c | d | e | f
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
def base_10_digit
|
|
96
|
-
zero | one | two | three | four | five | six | seven | eight | nine
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
def base_8_digit
|
|
100
|
-
zero | one | two | three | four | five | six | seven
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
def base_2_digit
|
|
104
|
-
zero | one
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
def base_16_whole
|
|
108
|
-
base_16_digit << (underscore.ignore | base_16_digit).repeat
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
def base_10_whole
|
|
112
|
-
base_10_digit << (underscore.ignore | base_10_digit).repeat
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
def base_8_whole
|
|
116
|
-
base_8_digit << (underscore.ignore | base_8_digit).repeat
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
def base_2_whole
|
|
120
|
-
base_2_digit << (underscore.ignore | base_2_digit).repeat
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
def exponent
|
|
124
|
-
(e << number).aka(:exponent)
|
|
125
|
-
end
|
|
126
|
-
|
|
127
|
-
def decimal
|
|
128
|
-
(base_10_whole << dot << base_10_whole).aka(:decimal) << exponent.maybe
|
|
129
|
-
end
|
|
130
|
-
|
|
131
|
-
def base_16_number
|
|
132
|
-
zero.ignore << x.ignore << base_16_whole
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
def base_10_number
|
|
136
|
-
base_10_whole.aka(:whole) << exponent.maybe
|
|
137
|
-
end
|
|
138
|
-
|
|
139
|
-
def base_8_number
|
|
140
|
-
zero.ignore << o.ignore << base_8_whole
|
|
141
|
-
end
|
|
142
|
-
|
|
143
|
-
def base_2_number
|
|
144
|
-
zero.ignore << b.ignore << base_2_whole
|
|
145
|
-
end
|
|
146
|
-
|
|
147
|
-
def root
|
|
148
|
-
(
|
|
149
|
-
decimal.aka(:decimal) | base_16_number.aka(:base_16) |
|
|
150
|
-
base_8_number.aka(:base_8) | base_2_number.aka(:base_2) |
|
|
151
|
-
base_10_number.aka(:base_10)
|
|
152
|
-
).aka(:number) | Boolean
|
|
153
|
-
end
|
|
154
|
-
end
|
|
155
|
-
end
|
|
156
|
-
end
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class Code
|
|
4
|
-
class Parser
|
|
5
|
-
class OrKeyword < LeftOperation
|
|
6
|
-
def statement
|
|
7
|
-
NotKeyword
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def separator
|
|
11
|
-
Name.new.separator
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def or_keyword
|
|
15
|
-
str("or") << separator.present
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def and_keyword
|
|
19
|
-
str("and") << separator.present
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def operator
|
|
23
|
-
or_keyword | and_keyword
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
data/lib/code/parser/power.rb
DELETED
data/lib/code/parser/range.rb
DELETED
data/lib/code/parser/rescue.rb
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class Code
|
|
4
|
-
class Parser
|
|
5
|
-
class RightOperation < Language
|
|
6
|
-
def statement
|
|
7
|
-
Statement
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def whitespace
|
|
11
|
-
Whitespace
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def whitespace?
|
|
15
|
-
whitespace.maybe
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def operator
|
|
19
|
-
str("")
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def right_statement
|
|
23
|
-
Statement
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def root
|
|
27
|
-
(
|
|
28
|
-
statement.aka(:left) << (
|
|
29
|
-
whitespace? << operator.aka(:operator) << whitespace? <<
|
|
30
|
-
right_statement.aka(:right)
|
|
31
|
-
).maybe
|
|
32
|
-
)
|
|
33
|
-
.aka(:right_operation)
|
|
34
|
-
.then do |output|
|
|
35
|
-
if output[:right_operation][:right]
|
|
36
|
-
output
|
|
37
|
-
else
|
|
38
|
-
output[:right_operation][:left]
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
end
|
data/lib/code/parser/shift.rb
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class Code
|
|
4
|
-
class Parser
|
|
5
|
-
class Shift < LeftOperation
|
|
6
|
-
def statement
|
|
7
|
-
Addition
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def greater
|
|
11
|
-
str(">")
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def lesser
|
|
15
|
-
str("<")
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def operator
|
|
19
|
-
(greater << greater) | (lesser << lesser)
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
data/lib/code/parser/splat.rb
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class Code
|
|
4
|
-
class Parser
|
|
5
|
-
class Splat < Language
|
|
6
|
-
def statement
|
|
7
|
-
Class
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def splat
|
|
11
|
-
Splat
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def whitespace
|
|
15
|
-
Whitespace
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def whitespace?
|
|
19
|
-
whitespace.maybe
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def ampersand
|
|
23
|
-
str("&")
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def root
|
|
27
|
-
(ampersand.aka(:operator) << whitespace? << splat.aka(:right)).aka(
|
|
28
|
-
:splat
|
|
29
|
-
) | statement
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class Code
|
|
4
|
-
class Parser
|
|
5
|
-
class SquareBracket < Language
|
|
6
|
-
def statement
|
|
7
|
-
UnaryMinus
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def whitespace
|
|
11
|
-
Whitespace
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def whitespace?
|
|
15
|
-
whitespace.maybe
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def left_square_bracket
|
|
19
|
-
str("[")
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def right_square_bracket
|
|
23
|
-
str("]")
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def root
|
|
27
|
-
(
|
|
28
|
-
statement.aka(:left) << (
|
|
29
|
-
left_square_bracket << whitespace? << Statement <<
|
|
30
|
-
(whitespace? << right_square_bracket).maybe
|
|
31
|
-
).repeat(1).aka(:statements).maybe
|
|
32
|
-
)
|
|
33
|
-
.aka(:square_bracket)
|
|
34
|
-
.then do |output|
|
|
35
|
-
if output[:square_bracket][:statements]
|
|
36
|
-
output
|
|
37
|
-
else
|
|
38
|
-
output[:square_bracket][:left]
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
end
|