riml 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
data/lib/compiler.rb CHANGED
@@ -25,7 +25,7 @@ module Riml
25
25
  end
26
26
 
27
27
  def visitor_for_node(node, params={})
28
- Compiler.const_get("#{node.class.name}Visitor").new(params)
28
+ Compiler.const_get("#{node.class.name.split('::').last}Visitor").new(params)
29
29
  end
30
30
  end
31
31
 
@@ -244,12 +244,15 @@ module Riml
244
244
  node.scope_modifier = scope_modifier_for_node(node)
245
245
  end
246
246
 
247
- private
248
247
  def scope_modifier_for_node(node)
249
248
  if node.scope
250
249
  if node.scope.function && DefNode === node && !node.defined_on_dictionary?
251
250
  return "s:"
252
- elsif node.respond_to?(:name) && node.scope.argument_variable_names.include?(node.name)
251
+ elsif node.scope.function && GetVariableNode === node &&
252
+ node.scope.function.shadowed_argument?(node.full_name)
253
+ return ""
254
+ elsif node.respond_to?(:name) && node.scope.argument_variable_names.include?(node.name) &&
255
+ !(AssignNode === node.parent && node.parent.lhs == node)
253
256
  return "a:"
254
257
  elsif !node.is_a?(CallNode)
255
258
  return ""
@@ -262,14 +265,37 @@ module Riml
262
265
 
263
266
  class AssignNodeVisitor < ScopedVisitor
264
267
  def compile(node)
265
- node.lhs.accept(visitor_for_node(node.lhs, :propagate_up_tree => false))
266
- node.compiled_output = "let #{node.lhs.compiled_output} #{node.operator} "
267
- node.rhs.parent_node = node
268
- node.rhs.accept(visitor_for_node(node.rhs))
268
+ first_shadow = nil
269
+
270
+ if GetVariableNode === node.lhs && node.scope && (func = node.scope.function)
271
+ if func.argument_variable_names.include?(node.lhs.full_name)
272
+ if !func.shadowed_argument_variable_names.include?(node.lhs.full_name)
273
+ first_shadow = true
274
+ end
275
+ end
276
+ end
277
+
278
+ lhs = visit_lhs(node)
279
+ rhs = visit_rhs(node)
280
+ if first_shadow
281
+ func.shadowed_argument_variable_names << node.lhs.full_name
282
+ end
283
+
284
+ node.compiled_output = "#{lhs}#{rhs}"
269
285
  node.compiled_output = "unlet! #{node.lhs.compiled_output}" if node.rhs.compiled_output == 'nil'
270
286
  node.force_newline = true
271
287
  node.compiled_output
272
288
  end
289
+
290
+ def visit_lhs(node)
291
+ node.lhs.accept(visitor_for_node(node.lhs, :propagate_up_tree => false))
292
+ "let #{node.lhs.compiled_output} #{node.operator} "
293
+ end
294
+
295
+ def visit_rhs(node)
296
+ node.rhs.accept(visitor_for_node(node.rhs, :propagate_up_tree => false))
297
+ node.rhs.compiled_output
298
+ end
273
299
  end
274
300
 
275
301
  # scope_modifier, name
@@ -277,9 +303,12 @@ module Riml
277
303
  def compile(node)
278
304
  set_modifier(node)
279
305
 
280
- if node.scope && node.scope.function? && (splat = node.scope.function.splat)
281
- check_for_splat_match!(node, splat)
306
+ if node.scope && node.scope.function?
307
+ if splat = node.scope.function.splat
308
+ check_for_splat_match!(node, splat)
309
+ end
282
310
  end
311
+
283
312
  if node.question_existence?
284
313
  node.compiled_output = %Q{exists("#{node.full_name}")}
285
314
  else
@@ -500,7 +529,8 @@ module Riml
500
529
  node.descendant_of_list_or_dict_get_node? ||
501
530
  node.descendant_of_operator_node? ||
502
531
  node.descendant_of_wrap_in_parens_node? ||
503
- node.descendant_of_sublist_node?
532
+ node.descendant_of_sublist_node? ||
533
+ node.descendant_of_dict_get_dot_node?
504
534
  node.force_newline = true
505
535
  end
506
536
  end
data/lib/constants.rb CHANGED
@@ -19,7 +19,7 @@ module Riml
19
19
  SPECIAL_VARIABLE_PREFIXES =
20
20
  %w(& @ $)
21
21
  BUILTIN_COMMANDS =
22
- %w(echo echon echomsg echoerr echohl execute sleep throw)
22
+ %w(echo echon echomsg echoerr echohl execute exec sleep throw)
23
23
  RIML_COMMANDS =
24
24
  %w(riml_source riml_include)
25
25
  VIML_COMMANDS =
@@ -36,10 +36,10 @@ module Riml
36
36
  # :help registers
37
37
  REGISTERS = [
38
38
  '"',
39
- (0..9).to_a.map(&:to_s),
39
+ ('0'..'9').to_a,
40
40
  '-',
41
- ('a'..'z').to_a.map(&:to_s),
42
- ('A'..'Z').to_a.map(&:to_s),
41
+ ('a'..'z').to_a,
42
+ ('A'..'Z').to_a,
43
43
  ':', '.', '%', '#',
44
44
  '=',
45
45
  '*', '+', '~',
data/lib/grammar.y CHANGED
@@ -37,17 +37,17 @@ preclow
37
37
  rule
38
38
 
39
39
  Root:
40
- /* nothing */ { result = Nodes.new([]) }
40
+ /* nothing */ { result = Riml::Nodes.new([]) }
41
41
  | Expressions { result = val[0] }
42
42
  ;
43
43
 
44
44
  # any list of expressions
45
45
  Expressions:
46
- AnyExpression { result = Nodes.new([ val[0] ]) }
46
+ AnyExpression { result = Riml::Nodes.new([ val[0] ]) }
47
47
  | Expressions Terminator AnyExpression { result = val[0] << val[2] }
48
48
  | Expressions Terminator { result = val[0] }
49
- | Terminator { result = Nodes.new([]) }
50
- | Terminator Expressions { result = Nodes.new(val[1]) }
49
+ | Terminator { result = Riml::Nodes.new([]) }
50
+ | Terminator Expressions { result = Riml::Nodes.new(val[1]) }
51
51
  ;
52
52
 
53
53
  # All types of expressions in Riml
@@ -75,10 +75,10 @@ rule
75
75
  ValueExpression:
76
76
  ValueExpressionWithoutDictLiteral { result = val[0] }
77
77
  | Dictionary { result = val[0] }
78
- | Dictionary DictGetWithDotLiteral { result = DictGetDotNode.new(val[0], val[1]) }
78
+ | Dictionary DictGetWithDotLiteral { result = Riml::DictGetDotNode.new(val[0], val[1]) }
79
79
  | BinaryOperator { result = val[0] }
80
80
  | Ternary { result = val[0] }
81
- | '(' ValueExpression ')' { result = WrapInParensNode.new(val[1]) }
81
+ | '(' ValueExpression ')' { result = Riml::WrapInParensNode.new(val[1]) }
82
82
  ;
83
83
 
84
84
  ValueExpressionWithoutDictLiteral:
@@ -90,7 +90,7 @@ rule
90
90
  | LiteralWithoutDictLiteral { result = val[0] }
91
91
  | Call { result = val[0] }
92
92
  | ObjectInstantiation { result = val[0] }
93
- | '(' ValueExpressionWithoutDictLiteral ')' { result = WrapInParensNode.new(val[1]) }
93
+ | '(' ValueExpressionWithoutDictLiteral ')' { result = Riml::WrapInParensNode.new(val[1]) }
94
94
  ;
95
95
 
96
96
  # for inside curly-brace variable names
@@ -115,36 +115,36 @@ rule
115
115
  | Regexp { result = val[0] }
116
116
  | List { result = val[0] }
117
117
  | ScopeModifierLiteral { result = val[0] }
118
- | TRUE { result = TrueNode.new }
119
- | FALSE { result = FalseNode.new }
120
- | NIL { result = NilNode.new }
118
+ | TRUE { result = Riml::TrueNode.new }
119
+ | FALSE { result = Riml::FalseNode.new }
120
+ | NIL { result = Riml::NilNode.new }
121
121
  ;
122
122
 
123
123
  Number:
124
- NUMBER { result = NumberNode.new(val[0]) }
124
+ NUMBER { result = Riml::NumberNode.new(val[0]) }
125
125
  ;
126
126
 
127
127
  String:
128
- STRING_S { result = StringNode.new(val[0], :s) }
129
- | STRING_D { result = StringNode.new(val[0], :d) }
130
- | String STRING_S { result = StringLiteralConcatNode.new(val[0], StringNode.new(val[1], :s)) }
131
- | String STRING_D { result = StringLiteralConcatNode.new(val[0], StringNode.new(val[1], :d)) }
128
+ STRING_S { result = Riml::StringNode.new(val[0], :s) }
129
+ | STRING_D { result = Riml::StringNode.new(val[0], :d) }
130
+ | String STRING_S { result = Riml::StringLiteralConcatNode.new(val[0], Riml::StringNode.new(val[1], :s)) }
131
+ | String STRING_D { result = Riml::StringLiteralConcatNode.new(val[0], Riml::StringNode.new(val[1], :d)) }
132
132
  ;
133
133
 
134
134
  Regexp:
135
- REGEXP { result = RegexpNode.new(val[0]) }
135
+ REGEXP { result = Riml::RegexpNode.new(val[0]) }
136
136
  ;
137
137
 
138
138
  ScopeModifierLiteral:
139
- SCOPE_MODIFIER_LITERAL { result = ScopeModifierLiteralNode.new(val[0]) }
139
+ SCOPE_MODIFIER_LITERAL { result = Riml::ScopeModifierLiteralNode.new(val[0]) }
140
140
  ;
141
141
 
142
142
  List:
143
- ListLiteral { result = ListNode.new(val[0]) }
143
+ ListLiteral { result = Riml::ListNode.new(val[0]) }
144
144
  ;
145
145
 
146
146
  ListUnpack:
147
- '[' ListItems ';' ValueExpression ']' { result = ListUnpackNode.new(val[1] << val[3]) }
147
+ '[' ListItems ';' ValueExpression ']' { result = Riml::ListUnpackNode.new(val[1] << val[3]) }
148
148
  ;
149
149
 
150
150
  ListLiteral:
@@ -159,7 +159,7 @@ rule
159
159
  ;
160
160
 
161
161
  Dictionary:
162
- DictionaryLiteral { result = DictionaryNode.new(val[0]) }
162
+ DictionaryLiteral { result = Riml::DictionaryNode.new(val[0]) }
163
163
  ;
164
164
 
165
165
  # {'key': 'value', 'key': 'value'}
@@ -181,14 +181,15 @@ rule
181
181
  ;
182
182
 
183
183
  DictGet:
184
- AllVariableRetrieval DictGetWithDot { result = DictGetDotNode.new(val[0], val[1]) }
185
- | ListOrDictGet DictGetWithDot { result = DictGetDotNode.new(val[0], val[1]) }
186
- | '(' ValueExpression ')' DictGetWithDot { result = DictGetDotNode.new(WrapInParensNode.new(val[1]), val[3]) }
184
+ AllVariableRetrieval DictGetWithDot { result = Riml::DictGetDotNode.new(val[0], val[1]) }
185
+ | ListOrDictGet DictGetWithDot { result = Riml::DictGetDotNode.new(val[0], val[1]) }
186
+ | Call DictGetWithDot { result = Riml::DictGetDotNode.new(val[0], val[1]) }
187
+ | '(' ValueExpression ')' DictGetWithDot { result = Riml::DictGetDotNode.new(Riml::WrapInParensNode.new(val[1]), val[3]) }
187
188
  ;
188
189
 
189
190
  ListOrDictGet:
190
- ValueExpressionWithoutDictLiteral ListOrDictGetWithBrackets { result = ListOrDictGetNode.new(val[0], val[1]) }
191
- | '(' ValueExpression ')' ListOrDictGetWithBrackets { result = ListOrDictGetNode.new(WrapInParensNode.new(val[1]), val[3]) }
191
+ ValueExpressionWithoutDictLiteral ListOrDictGetWithBrackets { result = Riml::ListOrDictGetNode.new(val[0], val[1]) }
192
+ | '(' ValueExpression ')' ListOrDictGetWithBrackets { result = Riml::ListOrDictGetNode.new(Riml::WrapInParensNode.new(val[1]), val[3]) }
192
193
  ;
193
194
 
194
195
  ListOrDictGetWithBrackets:
@@ -199,10 +200,10 @@ rule
199
200
  ;
200
201
 
201
202
  SubList:
202
- ValueExpression ':' ValueExpression { result = SublistNode.new([val[0], LiteralNode.new(' : '), val[2]]) }
203
- | ValueExpression ':' { result = SublistNode.new([val[0], LiteralNode.new(' :')]) }
204
- | ':' ValueExpression { result = SublistNode.new([LiteralNode.new(': '), val[1]]) }
205
- | ':' { result = SublistNode.new([LiteralNode.new(':')]) }
203
+ ValueExpression ':' ValueExpression { result = Riml::SublistNode.new([val[0], Riml::LiteralNode.new(' : '), val[2]]) }
204
+ | ValueExpression ':' { result = Riml::SublistNode.new([val[0], Riml::LiteralNode.new(' :')]) }
205
+ | ':' ValueExpression { result = Riml::SublistNode.new([Riml::LiteralNode.new(': '), val[1]]) }
206
+ | ':' { result = Riml::SublistNode.new([Riml::LiteralNode.new(':')]) }
206
207
  ;
207
208
 
208
209
  DictGetWithDot:
@@ -216,21 +217,21 @@ rule
216
217
  ;
217
218
 
218
219
  Call:
219
- Scope DefCallIdentifier '(' ArgList ')' { result = CallNode.new(val[0], val[1], val[3]) }
220
- | DictGet '(' ArgList ')' { result = CallNode.new(nil, val[0], val[2]) }
221
- | BUILTIN_COMMAND '(' ArgList ')' { result = CallNode.new(nil, val[0], val[2]) }
222
- | BUILTIN_COMMAND ArgList { result = CallNode.new(nil, val[0], val[1]) }
223
- | CALL '(' ArgList ')' { result = ExplicitCallNode.new(nil, nil, val[2]) }
220
+ Scope DefCallIdentifier '(' ArgList ')' { result = Riml::CallNode.new(val[0], val[1], val[3]) }
221
+ | DictGet '(' ArgList ')' { result = Riml::CallNode.new(nil, val[0], val[2]) }
222
+ | BUILTIN_COMMAND '(' ArgList ')' { result = Riml::CallNode.new(nil, val[0], val[2]) }
223
+ | BUILTIN_COMMAND ArgList { result = Riml::CallNode.new(nil, val[0], val[1]) }
224
+ | CALL '(' ArgList ')' { result = Riml::ExplicitCallNode.new(nil, nil, val[2]) }
224
225
  ;
225
226
 
226
227
  RimlCommand:
227
- RIML_COMMAND '(' ArgList ')' { result = RimlCommandNode.new(nil, val[0], val[2]) }
228
- | RIML_COMMAND ArgList { result = RimlCommandNode.new(nil, val[0], val[1]) }
228
+ RIML_COMMAND '(' ArgList ')' { result = Riml::RimlCommandNode.new(nil, val[0], val[2]) }
229
+ | RIML_COMMAND ArgList { result = Riml::RimlCommandNode.new(nil, val[0], val[1]) }
229
230
  ;
230
231
 
231
232
  ExplicitCall:
232
- CALL Scope DefCallIdentifier '(' ArgList ')' { result = ExplicitCallNode.new(val[1], val[2], val[4]) }
233
- | CALL DictGet '(' ArgList ')' { result = ExplicitCallNode.new(nil, val[1], val[3]) }
233
+ CALL Scope DefCallIdentifier '(' ArgList ')' { result = Riml::ExplicitCallNode.new(val[1], val[2], val[4]) }
234
+ | CALL DictGet '(' ArgList ')' { result = Riml::ExplicitCallNode.new(nil, val[1], val[3]) }
234
235
  ;
235
236
 
236
237
  Scope:
@@ -245,65 +246,65 @@ rule
245
246
  ;
246
247
 
247
248
  BinaryOperator:
248
- ValueExpression '||' ValueExpression { result = BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
249
- | ValueExpression '&&' ValueExpression { result = BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
249
+ ValueExpression '||' ValueExpression { result = Riml::BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
250
+ | ValueExpression '&&' ValueExpression { result = Riml::BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
250
251
 
251
- | ValueExpression '==' ValueExpression { result = BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
252
- | ValueExpression '==#' ValueExpression { result = BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
253
- | ValueExpression '==?' ValueExpression { result = BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
252
+ | ValueExpression '==' ValueExpression { result = Riml::BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
253
+ | ValueExpression '==#' ValueExpression { result = Riml::BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
254
+ | ValueExpression '==?' ValueExpression { result = Riml::BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
254
255
 
255
256
  # added by riml
256
- | ValueExpression '===' ValueExpression { result = BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
257
+ | ValueExpression '===' ValueExpression { result = Riml::BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
257
258
 
258
- | ValueExpression '!=' ValueExpression { result = BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
259
- | ValueExpression '!=#' ValueExpression { result = BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
260
- | ValueExpression '!=?' ValueExpression { result = BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
259
+ | ValueExpression '!=' ValueExpression { result = Riml::BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
260
+ | ValueExpression '!=#' ValueExpression { result = Riml::BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
261
+ | ValueExpression '!=?' ValueExpression { result = Riml::BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
261
262
 
262
- | ValueExpression '=~' ValueExpression { result = BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
263
- | ValueExpression '=~#' ValueExpression { result = BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
264
- | ValueExpression '=~?' ValueExpression { result = BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
263
+ | ValueExpression '=~' ValueExpression { result = Riml::BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
264
+ | ValueExpression '=~#' ValueExpression { result = Riml::BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
265
+ | ValueExpression '=~?' ValueExpression { result = Riml::BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
265
266
 
266
- | ValueExpression '!~' ValueExpression { result = BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
267
- | ValueExpression '!~#' ValueExpression { result = BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
268
- | ValueExpression '!~?' ValueExpression { result = BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
267
+ | ValueExpression '!~' ValueExpression { result = Riml::BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
268
+ | ValueExpression '!~#' ValueExpression { result = Riml::BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
269
+ | ValueExpression '!~?' ValueExpression { result = Riml::BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
269
270
 
270
- | ValueExpression '>' ValueExpression { result = BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
271
- | ValueExpression '>#' ValueExpression { result = BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
272
- | ValueExpression '>?' ValueExpression { result = BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
271
+ | ValueExpression '>' ValueExpression { result = Riml::BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
272
+ | ValueExpression '>#' ValueExpression { result = Riml::BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
273
+ | ValueExpression '>?' ValueExpression { result = Riml::BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
273
274
 
274
- | ValueExpression '>=' ValueExpression { result = BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
275
- | ValueExpression '>=#' ValueExpression { result = BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
276
- | ValueExpression '>=?' ValueExpression { result = BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
275
+ | ValueExpression '>=' ValueExpression { result = Riml::BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
276
+ | ValueExpression '>=#' ValueExpression { result = Riml::BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
277
+ | ValueExpression '>=?' ValueExpression { result = Riml::BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
277
278
 
278
- | ValueExpression '<' ValueExpression { result = BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
279
- | ValueExpression '<#' ValueExpression { result = BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
280
- | ValueExpression '<?' ValueExpression { result = BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
279
+ | ValueExpression '<' ValueExpression { result = Riml::BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
280
+ | ValueExpression '<#' ValueExpression { result = Riml::BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
281
+ | ValueExpression '<?' ValueExpression { result = Riml::BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
281
282
 
282
- | ValueExpression '<=' ValueExpression { result = BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
283
- | ValueExpression '<=#' ValueExpression { result = BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
284
- | ValueExpression '<=?' ValueExpression { result = BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
283
+ | ValueExpression '<=' ValueExpression { result = Riml::BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
284
+ | ValueExpression '<=#' ValueExpression { result = Riml::BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
285
+ | ValueExpression '<=?' ValueExpression { result = Riml::BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
285
286
 
286
- | ValueExpression '+' ValueExpression { result = BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
287
- | ValueExpression '-' ValueExpression { result = BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
288
- | ValueExpression '*' ValueExpression { result = BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
289
- | ValueExpression '/' ValueExpression { result = BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
290
- | ValueExpression '.' ValueExpression { result = BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
291
- | ValueExpression '%' ValueExpression { result = BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
287
+ | ValueExpression '+' ValueExpression { result = Riml::BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
288
+ | ValueExpression '-' ValueExpression { result = Riml::BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
289
+ | ValueExpression '*' ValueExpression { result = Riml::BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
290
+ | ValueExpression '/' ValueExpression { result = Riml::BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
291
+ | ValueExpression '.' ValueExpression { result = Riml::BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
292
+ | ValueExpression '%' ValueExpression { result = Riml::BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
292
293
 
293
- | ValueExpression IS ValueExpression { result = BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
294
- | ValueExpression ISNOT ValueExpression { result = BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
294
+ | ValueExpression IS ValueExpression { result = Riml::BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
295
+ | ValueExpression ISNOT ValueExpression { result = Riml::BinaryOperatorNode.new(val[1], [val[0], val[2]]) }
295
296
  ;
296
297
 
297
298
  UnaryOperator:
298
- '!' ValueExpression { result = UnaryOperatorNode.new(val[0], val[1]) }
299
- | '+' ValueExpression { result = UnaryOperatorNode.new(val[0], val[1]) }
300
- | '-' ValueExpression { result = UnaryOperatorNode.new(val[0], val[1]) }
299
+ '!' ValueExpression { result = Riml::UnaryOperatorNode.new(val[0], val[1]) }
300
+ | '+' ValueExpression { result = Riml::UnaryOperatorNode.new(val[0], val[1]) }
301
+ | '-' ValueExpression { result = Riml::UnaryOperatorNode.new(val[0], val[1]) }
301
302
  ;
302
303
 
303
304
  # ['=', LHS, RHS]
304
305
  Assign:
305
- LET AssignExpression { result = AssignNode.new(val[1][0], val[1][1], val[1][2]) }
306
- | AssignExpression { result = AssignNode.new(val[0][0], val[0][1], val[0][2]) }
306
+ LET AssignExpression { result = Riml::AssignNode.new(val[1][0], val[1][1], val[1][2]) }
307
+ | AssignExpression { result = Riml::AssignNode.new(val[0][0], val[0][1], val[0][2]) }
307
308
  ;
308
309
 
309
310
  # ['=', AssignLHS, Expression]
@@ -324,42 +325,42 @@ rule
324
325
 
325
326
  # retrieving the value of a variable
326
327
  VariableRetrieval:
327
- Scope IDENTIFIER { result = GetVariableNode.new(val[0], val[1]) }
328
- | SPECIAL_VAR_PREFIX IDENTIFIER { result = GetSpecialVariableNode.new(val[0], val[1]) }
329
- | ScopeModifierLiteral ListOrDictGetWithBrackets { result = GetVariableByScopeAndDictNameNode.new(val[0], val[1]) }
328
+ Scope IDENTIFIER { result = Riml::GetVariableNode.new(val[0], val[1]) }
329
+ | SPECIAL_VAR_PREFIX IDENTIFIER { result = Riml::GetSpecialVariableNode.new(val[0], val[1]) }
330
+ | ScopeModifierLiteral ListOrDictGetWithBrackets { result = Riml::GetVariableByScopeAndDictNameNode.new(val[0], val[1]) }
330
331
  ;
331
332
 
332
333
  AllVariableRetrieval:
333
334
  VariableRetrieval { result = val[0] }
334
- | Scope CurlyBraceName { result = GetCurlyBraceNameNode.new(val[0], val[1]) }
335
+ | Scope CurlyBraceName { result = Riml::GetCurlyBraceNameNode.new(val[0], val[1]) }
335
336
  ;
336
337
 
337
338
  UnletVariable:
338
- UNLET VariableRetrieval { result = UnletVariableNode.new('!', [ val[1] ]) }
339
- | UNLET_BANG VariableRetrieval { result = UnletVariableNode.new('!', [ val[1] ]) }
339
+ UNLET VariableRetrieval { result = Riml::UnletVariableNode.new('!', [ val[1] ]) }
340
+ | UNLET_BANG VariableRetrieval { result = Riml::UnletVariableNode.new('!', [ val[1] ]) }
340
341
  | UnletVariable VariableRetrieval { result = val[0] << val[1] }
341
342
  ;
342
343
 
343
344
  CurlyBraceName:
344
- CurlyBraceVarPart { result = CurlyBraceVariable.new([ val[0] ]) }
345
- | IDENTIFIER CurlyBraceName { result = CurlyBraceVariable.new([ CurlyBracePart.new(val[0]), val[1] ]) }
346
- | CurlyBraceName IDENTIFIER { result = val[0] << CurlyBracePart.new(val[1]) }
345
+ CurlyBraceVarPart { result = Riml::CurlyBraceVariable.new([ val[0] ]) }
346
+ | IDENTIFIER CurlyBraceName { result = Riml::CurlyBraceVariable.new([ Riml::CurlyBracePart.new(val[0]), val[1] ]) }
347
+ | CurlyBraceName IDENTIFIER { result = val[0] << Riml::CurlyBracePart.new(val[1]) }
347
348
  | CurlyBraceName CurlyBraceVarPart { result = val[0] << val[1] }
348
349
  ;
349
350
 
350
351
  CurlyBraceVarPart:
351
- '{' PossibleStringValue '}' { result = CurlyBracePart.new(val[1]) }
352
- | '{' PossibleStringValue CurlyBraceVarPart '}' { result = CurlyBracePart.new([val[1], val[2]]) }
353
- | '{' CurlyBraceVarPart PossibleStringValue '}' { result = CurlyBracePart.new([val[1], val[2]]) }
352
+ '{' PossibleStringValue '}' { result = Riml::CurlyBracePart.new(val[1]) }
353
+ | '{' PossibleStringValue CurlyBraceVarPart '}' { result = Riml::CurlyBracePart.new([val[1], val[2]]) }
354
+ | '{' CurlyBraceVarPart PossibleStringValue '}' { result = Riml::CurlyBracePart.new([val[1], val[2]]) }
354
355
  ;
355
356
 
356
357
  # Method definition
357
358
  # [scope_modifier, name, parameters, keyword, expressions]
358
359
  Def:
359
- FunctionType Scope DefCallIdentifier DefKeywords Block END { result = Object.const_get(val[0]).new('!', val[1], val[2], [], val[3], val[4]) }
360
- | FunctionType Scope DefCallIdentifier '(' ParamList ')' DefKeywords Block END { result = Object.const_get(val[0]).new('!', val[1], val[2], val[4], val[6], val[7]) }
361
- | FunctionType Scope DefCallIdentifier '(' SPLAT ')' DefKeywords Block END { result = Object.const_get(val[0]).new('!', val[1], val[2], [val[4]], val[6], val[7]) }
362
- | FunctionType Scope DefCallIdentifier '(' ParamList ',' SPLAT ')' DefKeywords Block END { result = Object.const_get(val[0]).new('!', val[1], val[2], val[4] << val[6], val[8], val[9]) }
360
+ FunctionType Scope DefCallIdentifier DefKeywords Block END { result = Riml.const_get(val[0]).new('!', val[1], val[2], [], val[3], val[4]) }
361
+ | FunctionType Scope DefCallIdentifier '(' ParamList ')' DefKeywords Block END { result = Riml.const_get(val[0]).new('!', val[1], val[2], val[4], val[6], val[7]) }
362
+ | FunctionType Scope DefCallIdentifier '(' SPLAT ')' DefKeywords Block END { result = Riml.const_get(val[0]).new('!', val[1], val[2], [val[4]], val[6], val[7]) }
363
+ | FunctionType Scope DefCallIdentifier '(' ParamList ',' SPLAT ')' DefKeywords Block END { result = Riml.const_get(val[0]).new('!', val[1], val[2], val[4] << val[6], val[8], val[9]) }
363
364
  ;
364
365
 
365
366
  FunctionType:
@@ -370,7 +371,7 @@ rule
370
371
 
371
372
  DefCallIdentifier:
372
373
  # use '' for first argument instead of nil in order to avoid a double scope-modifier
373
- CurlyBraceName { result = GetCurlyBraceNameNode.new('', val[0]) }
374
+ CurlyBraceName { result = Riml::GetCurlyBraceNameNode.new('', val[0]) }
374
375
  | IDENTIFIER { result = val[0] }
375
376
  ;
376
377
 
@@ -390,66 +391,66 @@ rule
390
391
  ;
391
392
 
392
393
  DefaultParam:
393
- IDENTIFIER '=' ValueExpression { result = DefaultParamNode.new(val[0], val[2]) }
394
+ IDENTIFIER '=' ValueExpression { result = Riml::DefaultParamNode.new(val[0], val[2]) }
394
395
  ;
395
396
 
396
397
  Return:
397
- RETURN ValueExpression { result = ReturnNode.new(val[1]) }
398
- | RETURN { result = ReturnNode.new(nil) }
398
+ RETURN ValueExpression { result = Riml::ReturnNode.new(val[1]) }
399
+ | RETURN { result = Riml::ReturnNode.new(nil) }
399
400
  ;
400
401
 
401
402
  EndScript:
402
- FINISH { result = FinishNode.new }
403
+ FINISH { result = Riml::FinishNode.new }
403
404
  ;
404
405
 
405
406
  # [expression, expressions]
406
407
  If:
407
- IF ValueExpression IfBlock END { result = IfNode.new(val[1], val[2]) }
408
- | IF ValueExpression THEN ValueExpression END { result = IfNode.new(val[1], Nodes.new([val[3]])) }
409
- | AnyExpression IF ValueExpression { result = IfNode.new(val[2], Nodes.new([val[0]])) }
408
+ IF ValueExpression IfBlock END { result = Riml::IfNode.new(val[1], val[2]) }
409
+ | IF ValueExpression THEN ValueExpression END { result = Riml::IfNode.new(val[1], Riml::Nodes.new([val[3]])) }
410
+ | AnyExpression IF ValueExpression { result = Riml::IfNode.new(val[2], Riml::Nodes.new([val[0]])) }
410
411
  ;
411
412
 
412
413
  Unless:
413
- UNLESS ValueExpression IfBlock END { result = UnlessNode.new(val[1], val[2]) }
414
- | UNLESS ValueExpression THEN ValueExpression END { result = UnlessNode.new(val[1], Nodes.new([val[3]])) }
415
- | ValueExpression UNLESS ValueExpression { result = UnlessNode.new(val[2], Nodes.new([val[0]])) }
414
+ UNLESS ValueExpression IfBlock END { result = Riml::UnlessNode.new(val[1], val[2]) }
415
+ | UNLESS ValueExpression THEN ValueExpression END { result = Riml::UnlessNode.new(val[1], Riml::Nodes.new([val[3]])) }
416
+ | ValueExpression UNLESS ValueExpression { result = Riml::UnlessNode.new(val[2], Riml::Nodes.new([val[0]])) }
416
417
  ;
417
418
 
418
419
  Ternary:
419
- ValueExpression '?' ValueExpression ':' ValueExpression { result = TernaryOperatorNode.new([val[0], val[2], val[4]]) }
420
+ ValueExpression '?' ValueExpression ':' ValueExpression { result = Riml::TernaryOperatorNode.new([val[0], val[2], val[4]]) }
420
421
  ;
421
422
 
422
423
  While:
423
- WHILE ValueExpression Block END { result = WhileNode.new(val[1], val[2]) }
424
+ WHILE ValueExpression Block END { result = Riml::WhileNode.new(val[1], val[2]) }
424
425
  ;
425
426
 
426
427
  LoopKeyword:
427
- BREAK { result = BreakNode.new }
428
- | CONTINUE { result = ContinueNode.new }
428
+ BREAK { result = Riml::BreakNode.new }
429
+ | CONTINUE { result = Riml::ContinueNode.new }
429
430
  ;
430
431
 
431
432
  Until:
432
- UNTIL ValueExpression Block END { result = UntilNode.new(val[1], val[2]) }
433
+ UNTIL ValueExpression Block END { result = Riml::UntilNode.new(val[1], val[2]) }
433
434
  ;
434
435
 
435
436
  For:
436
- FOR IDENTIFIER IN ValueExpression Block END { result = ForNode.new(val[1], val[3], val[4]) }
437
- | FOR List IN ValueExpression Block END { result = ForNode.new(val[1], val[3], val[4]) }
438
- | FOR ListUnpack IN ValueExpression Block END { result = ForNode.new(val[1], val[3], val[4]) }
437
+ FOR IDENTIFIER IN ValueExpression Block END { result = Riml::ForNode.new(val[1], val[3], val[4]) }
438
+ | FOR List IN ValueExpression Block END { result = Riml::ForNode.new(val[1], val[3], val[4]) }
439
+ | FOR ListUnpack IN ValueExpression Block END { result = Riml::ForNode.new(val[1], val[3], val[4]) }
439
440
  ;
440
441
 
441
442
  Try:
442
- TRY Block END { result = TryNode.new(val[1], nil, nil) }
443
- | TRY Block Catch END { result = TryNode.new(val[1], val[2], nil) }
444
- | TRY Block Catch FINALLY Block END { result = TryNode.new(val[1], val[2], val[4]) }
443
+ TRY Block END { result = Riml::TryNode.new(val[1], nil, nil) }
444
+ | TRY Block Catch END { result = Riml::TryNode.new(val[1], val[2], nil) }
445
+ | TRY Block Catch FINALLY Block END { result = Riml::TryNode.new(val[1], val[2], val[4]) }
445
446
  ;
446
447
 
447
448
  Catch:
448
449
  /* nothing */ { result = nil }
449
- | CATCH Block { result = [ CatchNode.new(nil, val[1]) ] }
450
- | CATCH Regexp Block { result = [ CatchNode.new(val[1], val[2]) ] }
451
- | Catch CATCH Block { result = val[0] << CatchNode.new(nil, val[2]) }
452
- | Catch CATCH Regexp Block { result = val[0] << CatchNode.new(val[2], val[3]) }
450
+ | CATCH Block { result = [ Riml::CatchNode.new(nil, val[1]) ] }
451
+ | CATCH Regexp Block { result = [ Riml::CatchNode.new(val[1], val[2]) ] }
452
+ | Catch CATCH Block { result = val[0] << Riml::CatchNode.new(nil, val[2]) }
453
+ | Catch CATCH Regexp Block { result = val[0] << Riml::CatchNode.new(val[2], val[3]) }
453
454
  ;
454
455
 
455
456
  # [expressions]
@@ -457,7 +458,7 @@ rule
457
458
  # itself
458
459
  Block:
459
460
  NEWLINE Expressions { result = val[1] }
460
- | NEWLINE { result = Nodes.new([]) }
461
+ | NEWLINE { result = Riml::Nodes.new([]) }
461
462
  ;
462
463
 
463
464
  IfBlock:
@@ -468,30 +469,30 @@ rule
468
469
  ;
469
470
 
470
471
  ElseBlock:
471
- ELSE NEWLINE Expressions { result = ElseNode.new(val[2]) }
472
+ ELSE NEWLINE Expressions { result = Riml::ElseNode.new(val[2]) }
472
473
  ;
473
474
 
474
475
  ElseifBlock:
475
- ELSEIF ValueExpression NEWLINE Expressions { result = Nodes.new([ElseifNode.new(val[1], val[3])]) }
476
- | ElseifBlock ELSEIF ValueExpression NEWLINE Expressions { result = val[0] << ElseifNode.new(val[2], val[4]) }
476
+ ELSEIF ValueExpression NEWLINE Expressions { result = Riml::Nodes.new([Riml::ElseifNode.new(val[1], val[3])]) }
477
+ | ElseifBlock ELSEIF ValueExpression NEWLINE Expressions { result = val[0] << Riml::ElseifNode.new(val[2], val[4]) }
477
478
  ;
478
479
 
479
480
  ClassDefinition:
480
- CLASS IDENTIFIER Block END { result = ClassDefinitionNode.new(val[1], nil, val[2]) }
481
- | CLASS IDENTIFIER '<' IDENTIFIER Block END { result = ClassDefinitionNode.new(val[1], val[3], val[4]) }
481
+ CLASS IDENTIFIER Block END { result = Riml::ClassDefinitionNode.new(val[1], nil, val[2]) }
482
+ | CLASS IDENTIFIER '<' IDENTIFIER Block END { result = Riml::ClassDefinitionNode.new(val[1], val[3], val[4]) }
482
483
  ;
483
484
 
484
485
  ObjectInstantiation:
485
- NEW Call { result = ObjectInstantiationNode.new(val[1]) }
486
+ NEW Call { result = Riml::ObjectInstantiationNode.new(val[1]) }
486
487
  ;
487
488
 
488
489
  Super:
489
- SUPER '(' ArgList ')' { result = SuperNode.new(val[2], true) }
490
- | SUPER { result = SuperNode.new([], false) }
490
+ SUPER '(' ArgList ')' { result = Riml::SuperNode.new(val[2], true) }
491
+ | SUPER { result = Riml::SuperNode.new([], false) }
491
492
  ;
492
493
 
493
494
  ExLiteral:
494
- EX_LITERAL { result = ExLiteralNode.new(val[0])}
495
+ EX_LITERAL { result = Riml::ExLiteralNode.new(val[0])}
495
496
  ;
496
497
  end
497
498
 
@@ -506,7 +507,7 @@ end
506
507
  attr_accessor :ast_rewriter
507
508
 
508
509
  # parses tokens or code into output nodes
509
- def parse(object, ast_rewriter = AST_Rewriter.new, include_file = nil)
510
+ def parse(object, ast_rewriter = Riml::AST_Rewriter.new, include_file = nil)
510
511
  if tokens?(object)
511
512
  @tokens = object
512
513
  elsif code?(object)