melbourne 1.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.
- data/HISTORY +3 -0
- data/LICENSE +27 -0
- data/README.rdoc +38 -0
- data/Rakefile +38 -0
- data/VERSION.yml +4 -0
- data/ext/melbourne/bstring-license.txt +29 -0
- data/ext/melbourne/bstrlib.c +2918 -0
- data/ext/melbourne/bstrlib.h +302 -0
- data/ext/melbourne/extconf.rb +76 -0
- data/ext/melbourne/grammar.cpp +11885 -0
- data/ext/melbourne/grammar.hpp +14 -0
- data/ext/melbourne/grammar.y +6013 -0
- data/ext/melbourne/internal.hpp +137 -0
- data/ext/melbourne/lex.c.tab +136 -0
- data/ext/melbourne/local_state.hpp +41 -0
- data/ext/melbourne/melbourne.cpp +37 -0
- data/ext/melbourne/node.hpp +262 -0
- data/ext/melbourne/node_types.cpp +245 -0
- data/ext/melbourne/node_types.hpp +135 -0
- data/ext/melbourne/node_types.rb +190 -0
- data/ext/melbourne/quark.cpp +52 -0
- data/ext/melbourne/quark.hpp +14 -0
- data/ext/melbourne/symbols.cpp +219 -0
- data/ext/melbourne/symbols.hpp +116 -0
- data/ext/melbourne/var_table.cpp +113 -0
- data/ext/melbourne/var_table.hpp +33 -0
- data/ext/melbourne/visitor.cpp +1052 -0
- data/ext/melbourne/visitor.hpp +20 -0
- data/lib/melbourne/ast/constants.rb +128 -0
- data/lib/melbourne/ast/control_flow.rb +382 -0
- data/lib/melbourne/ast/data.rb +19 -0
- data/lib/melbourne/ast/definitions.rb +561 -0
- data/lib/melbourne/ast/exceptions.rb +182 -0
- data/lib/melbourne/ast/file.rb +15 -0
- data/lib/melbourne/ast/grapher.rb +75 -0
- data/lib/melbourne/ast/literals.rb +268 -0
- data/lib/melbourne/ast/node.rb +21 -0
- data/lib/melbourne/ast/operators.rb +117 -0
- data/lib/melbourne/ast/self.rb +17 -0
- data/lib/melbourne/ast/sends.rb +451 -0
- data/lib/melbourne/ast/values.rb +74 -0
- data/lib/melbourne/ast/variables.rb +251 -0
- data/lib/melbourne/ast.rb +22 -0
- data/lib/melbourne/parser.rb +38 -0
- data/lib/melbourne/processor.rb +460 -0
- data/lib/melbourne.rb +46 -0
- data/spec/helpers/ast/node.rb +15 -0
- data/spec/helpers/ast/reduced_graph.rb +64 -0
- data/spec/lib/parser/alias_spec.rb +97 -0
- data/spec/lib/parser/and_spec.rb +63 -0
- data/spec/lib/parser/array_spec.rb +157 -0
- data/spec/lib/parser/attrasgn_spec.rb +401 -0
- data/spec/lib/parser/back_ref_spec.rb +20 -0
- data/spec/lib/parser/call_spec.rb +958 -0
- data/spec/lib/parser/case_spec.rb +577 -0
- data/spec/lib/parser/cdecl_spec.rb +108 -0
- data/spec/lib/parser/class_spec.rb +221 -0
- data/spec/lib/parser/colon2_spec.rb +13 -0
- data/spec/lib/parser/colon3_spec.rb +12 -0
- data/spec/lib/parser/const_spec.rb +12 -0
- data/spec/lib/parser/cvar_spec.rb +55 -0
- data/spec/lib/parser/cvasgn_spec.rb +71 -0
- data/spec/lib/parser/cvdecl_spec.rb +31 -0
- data/spec/lib/parser/defined_spec.rb +353 -0
- data/spec/lib/parser/defn_spec.rb +1409 -0
- data/spec/lib/parser/defs_spec.rb +247 -0
- data/spec/lib/parser/dot2_spec.rb +29 -0
- data/spec/lib/parser/dot3_spec.rb +29 -0
- data/spec/lib/parser/dregx_spec.rb +127 -0
- data/spec/lib/parser/dstr_spec.rb +453 -0
- data/spec/lib/parser/dsym_spec.rb +31 -0
- data/spec/lib/parser/dxstr_spec.rb +31 -0
- data/spec/lib/parser/ensure_spec.rb +279 -0
- data/spec/lib/parser/false_spec.rb +12 -0
- data/spec/lib/parser/flip2_spec.rb +138 -0
- data/spec/lib/parser/flip3_spec.rb +100 -0
- data/spec/lib/parser/for_spec.rb +279 -0
- data/spec/lib/parser/gasgn_spec.rb +34 -0
- data/spec/lib/parser/gvar_spec.rb +33 -0
- data/spec/lib/parser/hash_spec.rb +77 -0
- data/spec/lib/parser/iasgn_spec.rb +54 -0
- data/spec/lib/parser/if_spec.rb +439 -0
- data/spec/lib/parser/iter_spec.rb +2582 -0
- data/spec/lib/parser/lasgn_spec.rb +1066 -0
- data/spec/lib/parser/lit_spec.rb +75 -0
- data/spec/lib/parser/masgn_spec.rb +1970 -0
- data/spec/lib/parser/match2_spec.rb +47 -0
- data/spec/lib/parser/match3_spec.rb +54 -0
- data/spec/lib/parser/match_spec.rb +19 -0
- data/spec/lib/parser/module_spec.rb +102 -0
- data/spec/lib/parser/nil_spec.rb +13 -0
- data/spec/lib/parser/not_spec.rb +39 -0
- data/spec/lib/parser/nth_ref_spec.rb +12 -0
- data/spec/lib/parser/op_asgn_spec.rb +619 -0
- data/spec/lib/parser/or_spec.rb +155 -0
- data/spec/lib/parser/postexe_spec.rb +31 -0
- data/spec/lib/parser/regex_spec.rb +52 -0
- data/spec/lib/parser/rescue_spec.rb +1028 -0
- data/spec/lib/parser/return_spec.rb +151 -0
- data/spec/lib/parser/sclass_spec.rb +172 -0
- data/spec/lib/parser/str_spec.rb +162 -0
- data/spec/lib/parser/super_spec.rb +276 -0
- data/spec/lib/parser/true_spec.rb +12 -0
- data/spec/lib/parser/undef_spec.rb +222 -0
- data/spec/lib/parser/until_spec.rb +286 -0
- data/spec/lib/parser/valias_spec.rb +12 -0
- data/spec/lib/parser/while_spec.rb +458 -0
- data/spec/lib/parser/xstr_spec.rb +12 -0
- data/spec/lib/parser/yield_spec.rb +202 -0
- data/spec/lib/parser/zsuper_spec.rb +101 -0
- data/spec/matchers/parse_as.rb +27 -0
- data/spec/spec_helper.rb +10 -0
- metadata +168 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#ifndef MEL_VISITOR_HPP
|
|
2
|
+
#define MEL_VISITOR_HPP
|
|
3
|
+
|
|
4
|
+
#ifdef __cplusplus
|
|
5
|
+
extern "C" {
|
|
6
|
+
#endif
|
|
7
|
+
|
|
8
|
+
namespace melbourne {
|
|
9
|
+
rb_parse_state *alloc_parse_state();
|
|
10
|
+
void *pt_allocate(rb_parse_state *st, int size);
|
|
11
|
+
void pt_free(rb_parse_state *st);
|
|
12
|
+
void create_error(rb_parse_state *parse_state, char *msg);
|
|
13
|
+
NODE *node_newnode(rb_parse_state*, enum node_type, VALUE, VALUE, VALUE);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
#ifdef __cplusplus
|
|
17
|
+
} /* extern "C" { */
|
|
18
|
+
#endif
|
|
19
|
+
|
|
20
|
+
#endif
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
module Melbourne
|
|
2
|
+
|
|
3
|
+
module AST
|
|
4
|
+
|
|
5
|
+
# Access of a constant as in:
|
|
6
|
+
#
|
|
7
|
+
# X::Y # (X is the accessed constant)
|
|
8
|
+
#
|
|
9
|
+
class ConstAccess < Node
|
|
10
|
+
|
|
11
|
+
# The parent node
|
|
12
|
+
#
|
|
13
|
+
attr_accessor :parent
|
|
14
|
+
|
|
15
|
+
# The name of the node
|
|
16
|
+
#
|
|
17
|
+
attr_accessor :name
|
|
18
|
+
|
|
19
|
+
def initialize(line, parent, name) #:nodoc:
|
|
20
|
+
@line = line
|
|
21
|
+
@parent = parent
|
|
22
|
+
@name = name
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# A constant in the top level as in:
|
|
28
|
+
#
|
|
29
|
+
# ::X
|
|
30
|
+
#
|
|
31
|
+
class ConstAtTop < Node
|
|
32
|
+
|
|
33
|
+
# The parent node
|
|
34
|
+
#
|
|
35
|
+
attr_accessor :parent
|
|
36
|
+
|
|
37
|
+
# The name of the node
|
|
38
|
+
#
|
|
39
|
+
attr_accessor :name
|
|
40
|
+
|
|
41
|
+
def initialize(line, name) #:nodoc:
|
|
42
|
+
@line = line
|
|
43
|
+
@name = name
|
|
44
|
+
@parent = TopLevel.new line
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# The parent node of something on the lop level as in:
|
|
50
|
+
#
|
|
51
|
+
# ::X # X is at the top level, it's parent is the top level itself
|
|
52
|
+
#
|
|
53
|
+
class TopLevel < Node
|
|
54
|
+
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Access of a constant within some other code node (the constant has to be found then) as in
|
|
58
|
+
#
|
|
59
|
+
# def method
|
|
60
|
+
# String
|
|
61
|
+
# end
|
|
62
|
+
#
|
|
63
|
+
class ConstFind < Node
|
|
64
|
+
|
|
65
|
+
# The name of the node
|
|
66
|
+
#
|
|
67
|
+
attr_accessor :name
|
|
68
|
+
|
|
69
|
+
def initialize(line, name) #:nodoc:
|
|
70
|
+
@line = line
|
|
71
|
+
@name = name
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# Assignment of a value to a constant as in:
|
|
77
|
+
#
|
|
78
|
+
# X = 42
|
|
79
|
+
#
|
|
80
|
+
class ConstSet < Node
|
|
81
|
+
|
|
82
|
+
# The parent node
|
|
83
|
+
#
|
|
84
|
+
attr_accessor :parent
|
|
85
|
+
|
|
86
|
+
# The name of the node
|
|
87
|
+
#
|
|
88
|
+
attr_accessor :name
|
|
89
|
+
|
|
90
|
+
# The value that is set
|
|
91
|
+
#
|
|
92
|
+
attr_accessor :name
|
|
93
|
+
|
|
94
|
+
def initialize(line, name, value) #:nodoc:
|
|
95
|
+
@line = line
|
|
96
|
+
@value = value
|
|
97
|
+
@parent = nil
|
|
98
|
+
|
|
99
|
+
if name.kind_of? Symbol
|
|
100
|
+
@name = ConstName.new line, name
|
|
101
|
+
else
|
|
102
|
+
@parent = name.parent
|
|
103
|
+
@name = ConstName.new line, name.name
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# A constant's name in a constant's definition as in:
|
|
110
|
+
#
|
|
111
|
+
# X = 42
|
|
112
|
+
#
|
|
113
|
+
class ConstName < Node
|
|
114
|
+
|
|
115
|
+
# The name of the node
|
|
116
|
+
#
|
|
117
|
+
attr_accessor :name
|
|
118
|
+
|
|
119
|
+
def initialize(line, name) #:nodoc:
|
|
120
|
+
@line = line
|
|
121
|
+
@name = name
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
end
|
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
module Melbourne
|
|
2
|
+
|
|
3
|
+
module AST
|
|
4
|
+
|
|
5
|
+
# A +case+ statement as in
|
|
6
|
+
#
|
|
7
|
+
# case
|
|
8
|
+
# when a == 1 then
|
|
9
|
+
# # something
|
|
10
|
+
# when a == 2
|
|
11
|
+
# # something
|
|
12
|
+
# end
|
|
13
|
+
#
|
|
14
|
+
class Case < Node
|
|
15
|
+
|
|
16
|
+
# The +when+ nodes of the +case+ statement
|
|
17
|
+
#
|
|
18
|
+
attr_accessor :whens
|
|
19
|
+
|
|
20
|
+
# The +else+ node of the +case+ statement (or +nil+ if there is none)
|
|
21
|
+
#
|
|
22
|
+
attr_accessor :else
|
|
23
|
+
|
|
24
|
+
def initialize(line, whens, else_body) #:nodoc:
|
|
25
|
+
@line = line
|
|
26
|
+
@whens = whens
|
|
27
|
+
@else = else_body || Nil.new(line)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# A +case+ statement with a receiver as in:
|
|
33
|
+
#
|
|
34
|
+
# case a
|
|
35
|
+
# when 1 then
|
|
36
|
+
# # something
|
|
37
|
+
# when 2
|
|
38
|
+
# # something
|
|
39
|
+
# end
|
|
40
|
+
#
|
|
41
|
+
class ReceiverCase < Case
|
|
42
|
+
|
|
43
|
+
# The receiver of the +case+ statement
|
|
44
|
+
#
|
|
45
|
+
attr_accessor :receiver
|
|
46
|
+
|
|
47
|
+
def initialize(line, receiver, whens, else_body) #:nodoc:
|
|
48
|
+
@line = line
|
|
49
|
+
@receiver = receiver
|
|
50
|
+
@whens = whens
|
|
51
|
+
@else = else_body || Nil.new(line)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# A +when+ statement in a +case+ statement as in:
|
|
57
|
+
#
|
|
58
|
+
# case a
|
|
59
|
+
# when 1 then
|
|
60
|
+
# # something
|
|
61
|
+
# when 2
|
|
62
|
+
# # something
|
|
63
|
+
# end
|
|
64
|
+
#
|
|
65
|
+
class When < Node
|
|
66
|
+
|
|
67
|
+
# The conditions for which the +when+ statement is true or +nil+ if only a single value is specified
|
|
68
|
+
#
|
|
69
|
+
attr_accessor :conditions
|
|
70
|
+
|
|
71
|
+
# The body for the +when+ statement
|
|
72
|
+
#
|
|
73
|
+
attr_accessor :body
|
|
74
|
+
|
|
75
|
+
# The single value for the +when+ statement if only a single value is specified, +nil+ otherwise
|
|
76
|
+
#
|
|
77
|
+
attr_accessor :single
|
|
78
|
+
|
|
79
|
+
# Any splat (<tt>*something</tt>) that is specified as a condition for the +when+ statement or +nil+ of no splat is specified
|
|
80
|
+
#
|
|
81
|
+
attr_accessor :splat
|
|
82
|
+
|
|
83
|
+
def initialize(line, conditions, body) #:nodoc:
|
|
84
|
+
@line = line
|
|
85
|
+
@body = body || Nil.new(line)
|
|
86
|
+
@splat = nil
|
|
87
|
+
@single = nil
|
|
88
|
+
|
|
89
|
+
if conditions.kind_of? ArrayLiteral
|
|
90
|
+
if conditions.body.last.kind_of? When
|
|
91
|
+
last = conditions.body.pop
|
|
92
|
+
if last.conditions.kind_of? ArrayLiteral
|
|
93
|
+
conditions.body.concat last.conditions.body
|
|
94
|
+
elsif last.single
|
|
95
|
+
@splat = SplatWhen.new line, last.single
|
|
96
|
+
else
|
|
97
|
+
@splat = SplatWhen.new line, last.conditions
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
if conditions.body.size == 1 and !@splat
|
|
102
|
+
@single = conditions.body.first
|
|
103
|
+
else
|
|
104
|
+
@conditions = conditions
|
|
105
|
+
end
|
|
106
|
+
else
|
|
107
|
+
@conditions = conditions
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
# A splat (<tt>*something</tt>) inside a condition of a +when+ statement as in:
|
|
114
|
+
#
|
|
115
|
+
# case a
|
|
116
|
+
# when *c then
|
|
117
|
+
# d
|
|
118
|
+
# end
|
|
119
|
+
#
|
|
120
|
+
class SplatWhen < Node
|
|
121
|
+
|
|
122
|
+
# The actual content of the plat
|
|
123
|
+
#
|
|
124
|
+
attr_accessor :condition
|
|
125
|
+
|
|
126
|
+
def initialize(line, condition) #:nodoc:
|
|
127
|
+
@line = line
|
|
128
|
+
@condition = condition
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
# A flip statement as in:
|
|
134
|
+
#
|
|
135
|
+
# 1 if TRUE..FALSE
|
|
136
|
+
#
|
|
137
|
+
class Flip2 < Node
|
|
138
|
+
|
|
139
|
+
def initialize(line, start, finish) #:nodoc:
|
|
140
|
+
@line = line
|
|
141
|
+
@start = start
|
|
142
|
+
@finish = finish
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
# An end-exclusive flip statement as in:
|
|
148
|
+
#
|
|
149
|
+
# 1 if TRUE...FALSE
|
|
150
|
+
#
|
|
151
|
+
class Flip3 < Node
|
|
152
|
+
|
|
153
|
+
def initialize(line, start, finish) #:nodoc:
|
|
154
|
+
@line = line
|
|
155
|
+
@start = start
|
|
156
|
+
@finish = finish
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
# An +if+ statement as in:
|
|
162
|
+
#
|
|
163
|
+
# a if true
|
|
164
|
+
#
|
|
165
|
+
class If < Node
|
|
166
|
+
|
|
167
|
+
# The condition of the +if+ statement
|
|
168
|
+
#
|
|
169
|
+
attr_accessor :condition
|
|
170
|
+
|
|
171
|
+
# The body of the +if+ statement (the code that is executed if the +condition+ evaluates to true)
|
|
172
|
+
#
|
|
173
|
+
attr_accessor :body
|
|
174
|
+
|
|
175
|
+
# The +else+ block of the +if+ statement (if there is one)
|
|
176
|
+
#
|
|
177
|
+
attr_accessor :else
|
|
178
|
+
|
|
179
|
+
def initialize(line, condition, body, else_body) #:nodoc:
|
|
180
|
+
@line = line
|
|
181
|
+
@condition = condition
|
|
182
|
+
@body = body || Nil.new(line)
|
|
183
|
+
@else = else_body || Nil.new(line)
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
# A +while+ statement as in:
|
|
189
|
+
#
|
|
190
|
+
# i += 1 while go_on?
|
|
191
|
+
#
|
|
192
|
+
class While < Node
|
|
193
|
+
|
|
194
|
+
# The condition of the +while+ statement
|
|
195
|
+
#
|
|
196
|
+
attr_accessor :condition
|
|
197
|
+
|
|
198
|
+
# The body of the +while+ statement (the code that is executed if the +condition+ evaluates to true)
|
|
199
|
+
#
|
|
200
|
+
attr_accessor :body
|
|
201
|
+
|
|
202
|
+
# Whether to check the +while+ statement's condition before or after ths code in the +body+ is executed
|
|
203
|
+
#
|
|
204
|
+
attr_accessor :check_first
|
|
205
|
+
|
|
206
|
+
def initialize(line, condition, body, check_first) #:nodoc:
|
|
207
|
+
@line = line
|
|
208
|
+
@condition = condition
|
|
209
|
+
@body = body || Nil.new(line)
|
|
210
|
+
@check_first = check_first
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
# An +until+ statement as in:
|
|
216
|
+
#
|
|
217
|
+
# i += 1 until stop?
|
|
218
|
+
#
|
|
219
|
+
class Until < While
|
|
220
|
+
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
# A regular expression match statement as in:
|
|
224
|
+
#
|
|
225
|
+
# x =~ /x/
|
|
226
|
+
#
|
|
227
|
+
class Match < Node
|
|
228
|
+
|
|
229
|
+
# the regex pattern used for the match
|
|
230
|
+
#
|
|
231
|
+
attr_accessor :pattern
|
|
232
|
+
|
|
233
|
+
def initialize(line, pattern, flags) #:nodoc:
|
|
234
|
+
@line = line
|
|
235
|
+
@pattern = RegexLiteral.new line, pattern, flags
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
# A regular expression match statement with the regular expression pattern as the receiver as in:
|
|
241
|
+
#
|
|
242
|
+
# /x/ =~ x
|
|
243
|
+
#
|
|
244
|
+
class Match2 < Node
|
|
245
|
+
|
|
246
|
+
# the regex pattern used for the match
|
|
247
|
+
#
|
|
248
|
+
attr_accessor :pattern
|
|
249
|
+
|
|
250
|
+
# the value that is matched against the +pattern+
|
|
251
|
+
#
|
|
252
|
+
attr_accessor :value
|
|
253
|
+
|
|
254
|
+
def initialize(line, pattern, value) #:nodoc:
|
|
255
|
+
@line = line
|
|
256
|
+
@pattern = pattern
|
|
257
|
+
@value = value
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
end
|
|
261
|
+
|
|
262
|
+
# A regular expression match statement where a String is matched against the pattern as in:
|
|
263
|
+
#
|
|
264
|
+
# 'some' =~ /x/
|
|
265
|
+
#
|
|
266
|
+
class Match3 < Node
|
|
267
|
+
|
|
268
|
+
# the regex pattern used for the match
|
|
269
|
+
#
|
|
270
|
+
attr_accessor :pattern
|
|
271
|
+
|
|
272
|
+
# the value that is matched against the +pattern+
|
|
273
|
+
#
|
|
274
|
+
attr_accessor :value
|
|
275
|
+
|
|
276
|
+
def initialize(line, pattern, value) #:nodoc:
|
|
277
|
+
@line = line
|
|
278
|
+
@pattern = pattern
|
|
279
|
+
@value = value
|
|
280
|
+
end
|
|
281
|
+
|
|
282
|
+
end
|
|
283
|
+
|
|
284
|
+
# A +break+ statement as in:
|
|
285
|
+
#
|
|
286
|
+
# while true do
|
|
287
|
+
# begin
|
|
288
|
+
# x
|
|
289
|
+
# rescue Exception => x
|
|
290
|
+
# break
|
|
291
|
+
# end
|
|
292
|
+
# end
|
|
293
|
+
#
|
|
294
|
+
class Break < Node
|
|
295
|
+
|
|
296
|
+
# The value passed to +break+
|
|
297
|
+
#
|
|
298
|
+
attr_accessor :value
|
|
299
|
+
|
|
300
|
+
def initialize(line, expr) #:nodoc:
|
|
301
|
+
@line = line
|
|
302
|
+
@value = expr || Nil.new(line)
|
|
303
|
+
end
|
|
304
|
+
|
|
305
|
+
end
|
|
306
|
+
|
|
307
|
+
# A +next+ statement as in:
|
|
308
|
+
#
|
|
309
|
+
# while true do
|
|
310
|
+
# next if skip?(i)
|
|
311
|
+
# i += 1
|
|
312
|
+
# end
|
|
313
|
+
#
|
|
314
|
+
class Next < Break
|
|
315
|
+
|
|
316
|
+
def initialize(line, value) #:nodoc:
|
|
317
|
+
@line = line
|
|
318
|
+
@value = value
|
|
319
|
+
end
|
|
320
|
+
|
|
321
|
+
end
|
|
322
|
+
|
|
323
|
+
# A +redo+ statement as in:
|
|
324
|
+
#
|
|
325
|
+
# while true do
|
|
326
|
+
# begin
|
|
327
|
+
# x
|
|
328
|
+
# rescue Exception => x
|
|
329
|
+
# redo
|
|
330
|
+
# end
|
|
331
|
+
# end
|
|
332
|
+
#
|
|
333
|
+
class Redo < Break
|
|
334
|
+
|
|
335
|
+
def initialize(line) #:nodoc:
|
|
336
|
+
@line = line
|
|
337
|
+
end
|
|
338
|
+
|
|
339
|
+
end
|
|
340
|
+
|
|
341
|
+
# A +redo+ statement as in:
|
|
342
|
+
#
|
|
343
|
+
# while true do
|
|
344
|
+
# begin
|
|
345
|
+
# x
|
|
346
|
+
# rescue Exception => x
|
|
347
|
+
# try_to_fix()
|
|
348
|
+
# retry
|
|
349
|
+
# end
|
|
350
|
+
# end
|
|
351
|
+
#
|
|
352
|
+
class Retry < Break
|
|
353
|
+
|
|
354
|
+
def initialize(line) #:nodoc:
|
|
355
|
+
@line = line
|
|
356
|
+
end
|
|
357
|
+
|
|
358
|
+
end
|
|
359
|
+
|
|
360
|
+
# A +return+ statement as in:
|
|
361
|
+
#
|
|
362
|
+
# def method
|
|
363
|
+
# return 3
|
|
364
|
+
# end
|
|
365
|
+
#
|
|
366
|
+
class Return < Node
|
|
367
|
+
|
|
368
|
+
# The value passed to +return+
|
|
369
|
+
#
|
|
370
|
+
attr_accessor :value
|
|
371
|
+
|
|
372
|
+
def initialize(line, expr) #:nodoc:
|
|
373
|
+
@line = line
|
|
374
|
+
@value = expr
|
|
375
|
+
@splat = nil
|
|
376
|
+
end
|
|
377
|
+
|
|
378
|
+
end
|
|
379
|
+
|
|
380
|
+
end
|
|
381
|
+
|
|
382
|
+
end
|