minjs 0.4.0 → 0.4.1

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.
@@ -10,32 +10,32 @@ module Minjs::Lex
10
10
  # forward lexical parser position.
11
11
  # Otherwise return nil and position is not changed.
12
12
  #
13
- # @param context [Context] Lexical Environment
13
+ # @param var_env [EnvRecord] Lexical Environment
14
14
  #
15
15
  # @return [ECMA262::ECMA262Object] expression
16
16
  #
17
17
  # @see ECMA262 11.1
18
- def primary_exp(context)
18
+ def primary_exp(var_env)
19
19
  @logger.debug "*** primary_exp"
20
20
 
21
- if lex.eql_lit?(ECMA262::ID_THIS)
21
+ if eql_lit?(ECMA262::ID_THIS)
22
22
  @logger.debug "*** primary_exp => this"
23
- return ECMA262::This.new(context)
23
+ return ECMA262::This.new
24
24
  end
25
25
  # (exp)
26
- if lex.eql_lit?(ECMA262::PUNC_LPARENTHESIS)
27
- if a=exp(context, {}) and lex.eql_lit?(ECMA262::PUNC_RPARENTHESIS)
26
+ if eql_lit?(ECMA262::PUNC_LPARENTHESIS)
27
+ if a=exp(var_env, {}) and eql_lit?(ECMA262::PUNC_RPARENTHESIS)
28
28
  @logger.debug "*** primary_exp => ()"
29
29
  return ECMA262::ExpParen.new(a)
30
30
  else
31
- raise ParseError.new("no `)' at end of expression", lex)
31
+ raise ParseError.new("no `)' at end of expression", self)
32
32
  end
33
33
  end
34
34
 
35
- t = literal(context) ||
36
- identifier(context) ||
37
- array_literal(context) ||
38
- object_literal(context)
35
+ t = literal(var_env) ||
36
+ identifier(var_env) ||
37
+ array_literal(var_env) ||
38
+ object_literal(var_env)
39
39
 
40
40
  @logger.debug {
41
41
  "*** primary_exp => #{t ? t.to_js : t}"
@@ -50,29 +50,29 @@ module Minjs::Lex
50
50
  # forward lexical parser position.
51
51
  # Otherwise return nil and position is not changed.
52
52
  #
53
- # @param context [Context] Lexical Environment
53
+ # @param var_env [EnvRecord] Lexical Environment
54
54
  # @return [ECMA262::Base] expression
55
55
  #
56
56
  # @see ECMA262 7.8, 7.8.1, 7.8.2
57
- def literal(context)
57
+ def literal(var_env)
58
58
  # Literal ::
59
59
  # NullLiteral
60
60
  # BooleanLiteral
61
61
  # NumericLiteral
62
62
  # StringLiteral
63
63
  # RegularExpressionLiteral
64
- a = lex.peek_lit(:regexp)
64
+ a = peek_lit(:regexp)
65
65
  if a.kind_of? ECMA262::ECMA262Numeric or a.kind_of? ECMA262::ECMA262String or a.kind_of? ECMA262::ECMA262RegExp
66
- lex.fwd_after_peek
66
+ fwd_after_peek
67
67
  a
68
68
  elsif a .eql? ECMA262::ID_NULL
69
- lex.fwd_after_peek
69
+ fwd_after_peek
70
70
  ECMA262::Null.get
71
71
  elsif a .eql? ECMA262::ID_TRUE
72
- lex.fwd_after_peek
72
+ fwd_after_peek
73
73
  ECMA262::Boolean.get(:true)
74
74
  elsif a .eql? ECMA262::ID_FALSE
75
- lex.fwd_after_peek
75
+ fwd_after_peek
76
76
  ECMA262::Boolean.get(:false)
77
77
  else
78
78
  nil
@@ -86,16 +86,16 @@ module Minjs::Lex
86
86
  # forward lexical parser position.
87
87
  # Otherwise return nil and position is not changed.
88
88
  #
89
- # @param context [Context] Lexical Environment
89
+ # @param var_env [EnvRecord] Lexical Environment
90
90
  #
91
91
  # @return [ECMA262::Literal] expression
92
92
  #
93
93
  # @see ECMA262 11.1.2
94
- def identifier(context)
95
- a = lex.peek_lit(:regexp)
94
+ def identifier(var_env)
95
+ a = peek_lit(:regexp)
96
96
  if a.kind_of? ECMA262::IdentifierName and !a.reserved?
97
- lex.fwd_after_peek
98
- a.context = context
97
+ fwd_after_peek
98
+ #a.var_env = var_env
99
99
  a
100
100
  else
101
101
  nil
@@ -108,24 +108,24 @@ module Minjs::Lex
108
108
  # forward lexical parser position.
109
109
  # Otherwise return nil and position is not changed.
110
110
  #
111
- # @param context [Context] Lexical Environment
111
+ # @param var_env [EnvRecord] Lexical Environment
112
112
  #
113
113
  # @return [ECMA262::ECMA262Array] expression
114
114
  #
115
115
  # @see ECMA262 11.1.4
116
- def array_literal(context)
117
- return nil unless lex.eql_lit?(ECMA262::PUNC_LSQBRAC)
116
+ def array_literal(var_env)
117
+ return nil unless eql_lit?(ECMA262::PUNC_LSQBRAC)
118
118
  t = []
119
119
  while true
120
- if lex.eql_lit?(ECMA262::PUNC_COMMA)
120
+ if eql_lit?(ECMA262::PUNC_COMMA)
121
121
  t.push(nil)
122
- elsif lex.eql_lit?(ECMA262::PUNC_RSQBRAC)
122
+ elsif eql_lit?(ECMA262::PUNC_RSQBRAC)
123
123
  break
124
- elsif a = assignment_exp(context, {})
124
+ elsif a = assignment_exp(var_env, {})
125
125
  t.push(a)
126
- lex.eql_lit?(ECMA262::PUNC_COMMA)
126
+ eql_lit?(ECMA262::PUNC_COMMA)
127
127
  else
128
- raise ParseError.new("no `]' end of array", lex)
128
+ raise ParseError.new("no `]' end of array", self)
129
129
  end
130
130
  end
131
131
  ECMA262::ECMA262Array.new(t)
@@ -137,12 +137,12 @@ module Minjs::Lex
137
137
  # forward lexical parser position.
138
138
  # Otherwise return nil and position is not changed.
139
139
  #
140
- # @param context [Context] Lexical Environment
140
+ # @param var_env [EnvRecord] Lexical Environment
141
141
  #
142
142
  # @return [ECMA262::ECMA262Object] expression
143
143
  #
144
144
  # @see ECMA262 11.1.5
145
- def object_literal(context)
145
+ def object_literal(var_env)
146
146
  #
147
147
  # 11.1.5
148
148
  #
@@ -151,12 +151,12 @@ module Minjs::Lex
151
151
  # { PropertyNameAndValueList }
152
152
  # { PropertyNameAndValueList , }
153
153
  #
154
- return nil unless lex.eql_lit?(ECMA262::PUNC_LCURLYBRAC)
154
+ return nil unless eql_lit?(ECMA262::PUNC_LCURLYBRAC)
155
155
  #{}
156
- if lex.eql_lit?(ECMA262::PUNC_RCURLYBRAC)
156
+ if eql_lit?(ECMA262::PUNC_RCURLYBRAC)
157
157
  ECMA262::ECMA262Object.new([])
158
158
  else
159
- ECMA262::ECMA262Object.new(property_name_and_value_list(context))
159
+ ECMA262::ECMA262Object.new(property_name_and_value_list(var_env))
160
160
  end
161
161
  end
162
162
 
@@ -167,13 +167,13 @@ module Minjs::Lex
167
167
  # forward lexical parser position.
168
168
  # Otherwise return nil and position is not changed.
169
169
  #
170
- # @param context [Context] Lexical Environment
170
+ # @param var_env [EnvRecord] Lexical Environment
171
171
  #
172
172
  # @return [Array<Array>] expression
173
173
  #
174
174
  # @see ECMA262 11.1.5
175
175
  #
176
- def property_name_and_value_list(context)
176
+ def property_name_and_value_list(var_env)
177
177
  # PropertyNameAndValueList :
178
178
  # PropertyAssignment
179
179
  # PropertyNameAndValueList , PropertyAssignment
@@ -183,67 +183,65 @@ module Minjs::Lex
183
183
  # get PropertyName ( ) { FunctionBody }
184
184
  # set PropertyName ( PropertySetParameterList ) { FunctionBody }
185
185
  h = []
186
- while !lex.eof?
186
+ while !eof?
187
187
  #get
188
- if lex.match_lit? ECMA262::ID_GET
188
+ if match_lit? ECMA262::ID_GET
189
189
  # {get : val}
190
- if lex.eql_lit? ECMA262::PUNC_COLON
191
- b = assignment_exp(context, {})
190
+ if eql_lit? ECMA262::PUNC_COLON
191
+ b = assignment_exp(var_env, {})
192
192
  h.push([ECMA262::ID_GET, b])
193
193
  # {get name(){}}
194
194
  else
195
- new_context = ECMA262::Context.new
196
- new_context.lex_env = context.lex_env.new_declarative_env()
197
- new_context.var_env = context.var_env.new_declarative_env()
198
- if(a = property_name(context) and
199
- lex.eql_lit? ECMA262::PUNC_LPARENTHESIS and
200
- lex.eql_lit? ECMA262::PUNC_RPARENTHESIS and
201
- lex.eql_lit? ECMA262::PUNC_LCURLYBRAC and
202
- b = func_body(new_context) and
203
- lex.eql_lit? ECMA262::PUNC_RCURLYBRAC)
204
- h.push([a, ECMA262::StFunc.new(new_context, ECMA262::ID_GET, [], b, :getter => true)])
195
+ new_var_env = ECMA262::LexEnv.new(outer: var_env)
196
+ if(a = property_name(var_env) and
197
+ eql_lit? ECMA262::PUNC_LPARENTHESIS and
198
+ eql_lit? ECMA262::PUNC_RPARENTHESIS and
199
+ eql_lit? ECMA262::PUNC_LCURLYBRAC and
200
+ b = func_body(new_var_env) and
201
+ eql_lit? ECMA262::PUNC_RCURLYBRAC)
202
+ h.push([a, f = ECMA262::StFunc.new(new_var_env, ECMA262::ID_GET, [], b, :getter => true)])
203
+ #new_var_env.func = f
205
204
  else
206
- raise ParseError.new("unexpceted token", lex)
205
+ raise ParseError.new("unexpceted token", self)
207
206
  end
208
207
  end
209
208
  #set
210
- elsif lex.match_lit?(ECMA262::ID_SET)
209
+ elsif match_lit?(ECMA262::ID_SET)
211
210
  # {set : val}
212
- if lex.eql_lit? ECMA262::PUNC_COLON
213
- b = assignment_exp(context, {})
211
+ if eql_lit? ECMA262::PUNC_COLON
212
+ b = assignment_exp(var_env, {})
214
213
  h.push([ECMA262::ID_SET, b])
215
214
  # {set name(arg){}}
216
215
  else
217
- new_context = ECMA262::Context.new
218
- new_context.lex_env = context.lex_env.new_declarative_env()
219
- new_context.var_env = context.var_env.new_declarative_env()
220
- if(a = property_name(context) and
221
- lex.eql_lit? ECMA262::PUNC_LPARENTHESIS and
222
- arg = property_set_parameter_list(new_context) and
223
- lex.eql_lit? ECMA262::PUNC_RPARENTHESIS and
224
- lex.eql_lit? ECMA262::PUNC_LCURLYBRAC and
225
- b = func_body(new_context) and
226
- lex.eql_lit? ECMA262::PUNC_RCURLYBRAC)
227
- h.push([a, ECMA262::StFunc.new(new_context, ECMA262::ID_SET, arg, b, :setter => true)])
216
+ new_var_env = ECMA262::LexEnv.new(outer: var_env)
217
+ if(a = property_name(var_env) and
218
+ eql_lit? ECMA262::PUNC_LPARENTHESIS and
219
+ arg = property_set_parameter_list(new_var_env) and
220
+ eql_lit? ECMA262::PUNC_RPARENTHESIS and
221
+ eql_lit? ECMA262::PUNC_LCURLYBRAC and
222
+ b = func_body(new_var_env) and
223
+ eql_lit? ECMA262::PUNC_RCURLYBRAC)
224
+ h.push([a, f = ECMA262::StFunc.new(new_var_env, ECMA262::ID_SET, arg, b, :setter => true)])
225
+ #new_var_env.func = f
228
226
  else
229
- raise ParseError.new("unexpceted token", lex)
227
+ raise ParseError.new("unexpceted token", self)
230
228
  end
231
229
  end
232
230
  #property
233
- elsif(a = property_name(context) and
234
- lex.eql_lit? ECMA262::PUNC_COLON and
235
- b = assignment_exp(context, {}))
231
+ elsif(a = property_name(var_env) and
232
+ eql_lit? ECMA262::PUNC_COLON and
233
+ b = assignment_exp(var_env, {}))
236
234
  h.push([a, b])
237
235
  else
238
- raise ParseError.new("unexpceted token", lex)
236
+ raise ParseError.new("unexpceted token", self)
239
237
  end
240
238
 
241
- if lex.eql_lit?(ECMA262::PUNC_COMMA)
242
- break if lex.eql_lit?(ECMA262::PUNC_RCURLYBRAC)
243
- elsif lex.eql_lit?(ECMA262::PUNC_RCURLYBRAC)
239
+ if eql_lit?(ECMA262::PUNC_COMMA)
240
+ break if eql_lit?(ECMA262::PUNC_RCURLYBRAC)
241
+ elsif eql_lit?(ECMA262::PUNC_RCURLYBRAC)
244
242
  break
245
243
  else
246
- raise ParseError.new("no `}' end of object", lex)
244
+ raise ParseError.new("no `}' end of object", self)
247
245
  end
248
246
  end
249
247
  h
@@ -256,7 +254,7 @@ module Minjs::Lex
256
254
  # forward lexical parser position.
257
255
  # Otherwise return nil and position is not changed.
258
256
  #
259
- # @param context [Context] Lexical Environment
257
+ # @param var_env [EnvRecord] Lexical Environment
260
258
  #
261
259
  # @return [ECMA262::Base] expression
262
260
  #
@@ -264,12 +262,12 @@ module Minjs::Lex
264
262
  # 11.1.5
265
263
  #
266
264
  #
267
- def property_name(context)
265
+ def property_name(var_env)
268
266
  # PropertyName :
269
267
  # IdentifierName
270
268
  # StringLiteral
271
269
  # NumericLiteral
272
- a = lex.fwd_lit(nil)
270
+ a = fwd_lit(nil)
273
271
  if a.kind_of?(ECMA262::ECMA262String)
274
272
  a
275
273
  elsif a.kind_of?(ECMA262::IdentifierName)
@@ -279,7 +277,7 @@ module Minjs::Lex
279
277
  elsif a.eql?(ECMA262::PUNC_COLON)
280
278
  nil
281
279
  else
282
- raise ParseError.new("unexpceted token", lex)
280
+ raise ParseError.new("unexpceted token", self)
283
281
  end
284
282
  end
285
283
 
@@ -290,19 +288,18 @@ module Minjs::Lex
290
288
  # forward lexical parser position.
291
289
  # Otherwise return nil and position is not changed.
292
290
  #
293
- # @param context [Context] Lexical Environment
291
+ # @param var_env [EnvRecord] Lexical Environment
294
292
  #
295
293
  # @return [Array<ECMA262::Base>] arguments
296
294
  #
297
295
  # @see ECMA262 11.1.5
298
- def property_set_parameter_list(context)
296
+ def property_set_parameter_list(var_env)
299
297
  # PropertySetParameterList :
300
298
  # Identifier
301
- argName = identifier(context)
302
- context.var_env.record.create_mutable_binding(argName, nil)
303
- context.var_env.record.set_mutable_binding(argName, :undefined, nil, {:_parameter_list => true})
304
- context.lex_env.record.create_mutable_binding(argName, nil)
305
- context.lex_env.record.set_mutable_binding(argName, :undefined, nil, {:_parameter_list => true})
299
+ argName = identifier(var_env)
300
+
301
+ var_env.record.create_mutable_binding(argName, nil)
302
+ var_env.record.set_mutable_binding(argName, :undefined, nil, _parameter_list: true)
306
303
  [argName]
307
304
  end
308
305
 
@@ -313,11 +310,11 @@ module Minjs::Lex
313
310
  # forward lexical parser position.
314
311
  # Otherwise return nil and position is not changed.
315
312
  #
316
- # @param context [Context] Lexical Environment
313
+ # @param var_env [EnvRecord] Lexical Environment
317
314
  # @return [ECMA262::Base] expression
318
315
  #
319
316
  # @see ECMA262 11.2
320
- def left_hand_side_exp(context)
317
+ def left_hand_side_exp(var_env)
321
318
  #
322
319
  # LeftHandSideExpression :
323
320
  # NewExpression
@@ -325,8 +322,8 @@ module Minjs::Lex
325
322
  #
326
323
  @logger.debug "*** left_hand_side_exp"
327
324
 
328
- t = call_exp(context) || new_exp(context)
329
- #t = new_exp(context) || call_exp(context)
325
+ t = call_exp(var_env) || new_exp(var_env)
326
+ #t = new_exp(var_env) || call_exp(var_env)
330
327
 
331
328
  @logger.debug{
332
329
  "*** left_hand_side_exp => #{t ? t.to_js: t}"
@@ -364,23 +361,23 @@ module Minjs::Lex
364
361
  # MemberExpression [lookahead ∉ {(}]
365
362
  # new NewExpression [lookahead ∉ {(}]
366
363
  #
367
- # @param context [Context] Lexical Environment
364
+ # @param var_env [EnvRecord] Lexical Environment
368
365
  # @option options :no_in [Boolean] If set, the parser interpret as RelationExpressionNoIn
369
366
  #
370
367
  # @return [ECMA262::Base] expression
371
368
  #
372
369
  # @see ECMA262 11.2
373
370
  # @see #call_exp
374
- def new_exp(context)
371
+ def new_exp(var_env)
375
372
  # NewExpression :
376
373
  # MemberExpression
377
374
  # new NewExpression
378
- if lex.eql_lit?(ECMA262::ID_NEW)
379
- if a = new_exp(context)
380
- if lex.eql_lit? ECMA262::PUNC_LPARENTHESIS
375
+ if eql_lit?(ECMA262::ID_NEW)
376
+ if a = new_exp(var_env)
377
+ if eql_lit? ECMA262::PUNC_LPARENTHESIS
381
378
  # minjs evaluate CallExpression first, so
382
379
  # program never falls to here.
383
- raise ParseError.new("unexpceted token", lex)
380
+ raise ParseError.new("unexpceted token", self)
384
381
  nil # this is not NewExpression, may be MemberExpression.
385
382
  end
386
383
  #puts "new_exp> #{a.to_js}"
@@ -388,11 +385,11 @@ module Minjs::Lex
388
385
  else
389
386
  # minjs evaluate CallExpression first, so
390
387
  # raise exception when program falls to here.
391
- raise ParseError.new("unexpceted token", lex)
388
+ raise ParseError.new("unexpceted token", self)
392
389
  #nil
393
390
  end
394
391
  else
395
- member_exp(context)
392
+ member_exp(var_env)
396
393
  end
397
394
  end
398
395
  # Tests next literal is CallExpression or not.
@@ -404,14 +401,14 @@ module Minjs::Lex
404
401
  #
405
402
  # @see ECMA262 11.2
406
403
  # @see #new_exp
407
- def call_exp(context)
404
+ def call_exp(var_env)
408
405
  # CallExpression :
409
406
  # MemberExpression Arguments
410
407
  # CallExpression Arguments
411
408
  # CallExpression [ Expression ]
412
409
  # CallExpression . IdentifierName
413
- if a = member_exp(context)
414
- if b = arguments(context)
410
+ if a = member_exp(var_env)
411
+ if b = arguments(var_env)
415
412
  t = ECMA262::ExpCall.new(a, b)
416
413
  # if b is nil, this may be MemberExpression of NewExpression
417
414
  else
@@ -422,19 +419,19 @@ module Minjs::Lex
422
419
  end
423
420
 
424
421
  while true
425
- if b = arguments(context)
422
+ if b = arguments(var_env)
426
423
  t = ECMA262::ExpCall.new(t, b)
427
- elsif lex.eql_lit?(ECMA262::PUNC_LSQBRAC)
428
- if b=exp(context, {}) and lex.eql_lit?(ECMA262::PUNC_RSQBRAC)
424
+ elsif eql_lit?(ECMA262::PUNC_LSQBRAC)
425
+ if b=exp(var_env, {}) and eql_lit?(ECMA262::PUNC_RSQBRAC)
429
426
  t = ECMA262::ExpPropBrac.new(t, b)
430
427
  else
431
- raise ParseError.new("unexpceted token", lex)
428
+ raise ParseError.new("unexpceted token", self)
432
429
  end
433
- elsif lex.eql_lit?(ECMA262::PUNC_PERIOD)
434
- if (b=lex.fwd_lit(nil)).kind_of?(ECMA262::IdentifierName)
430
+ elsif eql_lit?(ECMA262::PUNC_PERIOD)
431
+ if (b=fwd_lit(nil)).kind_of?(ECMA262::IdentifierName)
435
432
  t = ECMA262::ExpProp.new(t, b)
436
433
  else
437
- raise ParseError.new("unexpceted token", lex)
434
+ raise ParseError.new("unexpceted token", self)
438
435
  end
439
436
  else
440
437
  break
@@ -450,14 +447,14 @@ module Minjs::Lex
450
447
  # forward lexical parser position.
451
448
  # Otherwise return nil and position is not changed.
452
449
  #
453
- # @param context [Context] Lexical Environment
450
+ # @param var_env [EnvRecord] Lexical Environment
454
451
  # @option options :no_in [Boolean] If set, the parser interpret as RelationExpressionNoIn
455
452
  #
456
453
  # @return [ECMA262::Base] expression
457
454
  #
458
455
  # @see ECMA262 11.2
459
456
  #
460
- def member_exp(context)
457
+ def member_exp(var_env)
461
458
  # MemberExpression :
462
459
  # PrimaryExpression
463
460
  # FunctionExpression
@@ -465,10 +462,10 @@ module Minjs::Lex
465
462
  # MemberExpression . IdentifierName
466
463
  # new MemberExpression Arguments
467
464
  #
468
- t = lex.eval_lit{
469
- if lex.eql_lit? ECMA262::ID_NEW
470
- if a = member_exp(context)
471
- b = arguments(context)
465
+ t = eval_lit{
466
+ if eql_lit? ECMA262::ID_NEW
467
+ if a = member_exp(var_env)
468
+ b = arguments(var_env)
472
469
  # if b is nil, this may be NewExpression
473
470
  if b
474
471
  s = b.collect{|x| x.to_js}.join(',');
@@ -481,21 +478,21 @@ module Minjs::Lex
481
478
  return nil
482
479
  end
483
480
  end
484
- } || primary_exp(context) || func_exp(context)
481
+ } || primary_exp(var_env) || func_exp(var_env)
485
482
  return nil if t.nil?
486
483
 
487
484
  while true
488
- if lex.eql_lit?(ECMA262::PUNC_LSQBRAC)
489
- if b=exp(context, {}) and lex.eql_lit?(ECMA262::PUNC_RSQBRAC)
485
+ if eql_lit?(ECMA262::PUNC_LSQBRAC)
486
+ if b=exp(var_env, {}) and eql_lit?(ECMA262::PUNC_RSQBRAC)
490
487
  t = ECMA262::ExpPropBrac.new(t, b)
491
488
  else
492
- raise ParseError.new("unexpceted token", lex)
489
+ raise ParseError.new("unexpceted token", self)
493
490
  end
494
- elsif lex.eql_lit?(ECMA262::PUNC_PERIOD)
495
- if (b=lex.fwd_lit(nil)).kind_of?(ECMA262::IdentifierName)
491
+ elsif eql_lit?(ECMA262::PUNC_PERIOD)
492
+ if (b=fwd_lit(nil)).kind_of?(ECMA262::IdentifierName)
496
493
  t = ECMA262::ExpProp.new(t, b)
497
494
  else
498
- raise ParseError.new("unexpceted token", lex)
495
+ raise ParseError.new("unexpceted token", self)
499
496
  end
500
497
  else
501
498
  break
@@ -510,31 +507,31 @@ module Minjs::Lex
510
507
  # forward lexical parser position.
511
508
  # Otherwise return nil and position is not changed.
512
509
  #
513
- # @param context [Context] Lexical Environment
510
+ # @param var_env [EnvRecord] Lexical Environment
514
511
  #
515
512
  # @return [Array<ECMA262::Base>] arguments
516
513
  #
517
514
  # @see ECMA262 11.2
518
- def arguments(context)
515
+ def arguments(var_env)
519
516
  # Arguments :
520
517
  # ( )
521
518
  # ( ArgumentList )
522
- return nil if lex.eql_lit?(ECMA262::PUNC_LPARENTHESIS).nil?
523
- return [] if lex.eql_lit?(ECMA262::PUNC_RPARENTHESIS)
519
+ return nil if eql_lit?(ECMA262::PUNC_LPARENTHESIS).nil?
520
+ return [] if eql_lit?(ECMA262::PUNC_RPARENTHESIS)
524
521
 
525
522
  args = []
526
523
  while true
527
- if t = assignment_exp(context, {})
524
+ if t = assignment_exp(var_env, {})
528
525
  args.push(t)
529
526
  else
530
- raise ParseError.new("unexpected token", lex)
527
+ raise ParseError.new("unexpected token", self)
531
528
  end
532
- if lex.eql_lit?(ECMA262::PUNC_COMMA)
529
+ if eql_lit?(ECMA262::PUNC_COMMA)
533
530
  ;
534
- elsif lex.eql_lit?(ECMA262::PUNC_RPARENTHESIS)
531
+ elsif eql_lit?(ECMA262::PUNC_RPARENTHESIS)
535
532
  break
536
533
  else
537
- raise ParseError.new("unexpected token", lex)
534
+ raise ParseError.new("unexpected token", self)
538
535
  end
539
536
  end
540
537
  args
@@ -547,16 +544,16 @@ module Minjs::Lex
547
544
  # forward lexical parser position.
548
545
  # Otherwise return nil and position is not changed.
549
546
  #
550
- # @param context [Context] Lexical Environment
547
+ # @param var_env [EnvRecord] Lexical Environment
551
548
  #
552
549
  # @return [ECMA262::ECMA262Object] expression
553
550
  #
554
551
  # @see ECMA262 11.3
555
- def postfix_exp(context)
556
- exp = left_hand_side_exp(context)
552
+ def postfix_exp(var_env)
553
+ exp = left_hand_side_exp(var_env)
557
554
  return nil if exp.nil?
558
- if punc = (lex.eql_lit_nolt?(ECMA262::PUNC_INC) ||
559
- lex.eql_lit_nolt?(ECMA262::PUNC_DEC))
555
+ if punc = (eql_lit_nolt?(ECMA262::PUNC_INC) ||
556
+ eql_lit_nolt?(ECMA262::PUNC_DEC))
560
557
  if punc == ECMA262::PUNC_INC
561
558
  ECMA262::ExpPostInc.new(exp)
562
559
  else
@@ -574,24 +571,24 @@ module Minjs::Lex
574
571
  # forward lexical parser position.
575
572
  # Otherwise return nil and position is not changed.
576
573
  #
577
- # @param context [Context] Lexical Environment
574
+ # @param var_env [EnvRecord] Lexical Environment
578
575
  # @option options :no_in [Boolean] If set, the parser interpret as RelationExpressionNoIn
579
576
  # @return [ECMA262::Base] expression
580
577
  #
581
578
  # see ECMA262 11.4
582
- def unary_exp(context)
583
- if punc = (lex.eql_lit?(ECMA262::ID_DELETE) ||
584
- lex.eql_lit?(ECMA262::ID_VOID) ||
585
- lex.eql_lit?(ECMA262::ID_TYPEOF) ||
586
- lex.eql_lit?(ECMA262::PUNC_INC) ||
587
- lex.eql_lit?(ECMA262::PUNC_DEC) ||
588
- lex.eql_lit?(ECMA262::PUNC_ADD) ||
589
- lex.eql_lit?(ECMA262::PUNC_SUB) ||
590
- lex.eql_lit?(ECMA262::PUNC_NOT) ||
591
- lex.eql_lit?(ECMA262::PUNC_LNOT))
592
- exp = unary_exp(context)
579
+ def unary_exp(var_env)
580
+ if punc = (eql_lit?(ECMA262::ID_DELETE) ||
581
+ eql_lit?(ECMA262::ID_VOID) ||
582
+ eql_lit?(ECMA262::ID_TYPEOF) ||
583
+ eql_lit?(ECMA262::PUNC_INC) ||
584
+ eql_lit?(ECMA262::PUNC_DEC) ||
585
+ eql_lit?(ECMA262::PUNC_ADD) ||
586
+ eql_lit?(ECMA262::PUNC_SUB) ||
587
+ eql_lit?(ECMA262::PUNC_NOT) ||
588
+ eql_lit?(ECMA262::PUNC_LNOT))
589
+ exp = unary_exp(var_env)
593
590
  if exp.nil?
594
- raise ParseError.new("unexpceted token", lex)
591
+ raise ParseError.new("unexpceted token", self)
595
592
  elsif punc == ECMA262::PUNC_INC
596
593
  ECMA262::ExpPreInc.new(exp)
597
594
  elsif punc == ECMA262::PUNC_DEC
@@ -614,7 +611,7 @@ module Minjs::Lex
614
611
  end
615
612
  end
616
613
  else
617
- postfix_exp(context)
614
+ postfix_exp(var_env)
618
615
  end
619
616
  end
620
617
 
@@ -625,21 +622,21 @@ module Minjs::Lex
625
622
  # forward lexical parser position.
626
623
  # Otherwise return nil and position is not changed.
627
624
  #
628
- # @param context [Context] Lexical Environment
625
+ # @param var_env [EnvRecord] Lexical Environment
629
626
  # @option options :no_in [Boolean] If set, the parser interpret as RelationExpressionNoIn
630
627
  #
631
628
  # @return [ECMA262::Base] expression
632
629
  #
633
630
  # @see ECMA262 11.5
634
- def multiplicative_exp(context)
635
- a = unary_exp(context)
631
+ def multiplicative_exp(var_env)
632
+ a = unary_exp(var_env)
636
633
  return nil if !a
637
634
  t = a
638
- while punc = lex.eql_lit?(ECMA262::PUNC_MUL) ||
639
- lex.eql_lit?(ECMA262::PUNC_DIV, :div) ||
640
- lex.eql_lit?(ECMA262::PUNC_MOD)
635
+ while punc = eql_lit?(ECMA262::PUNC_MUL) ||
636
+ eql_lit?(ECMA262::PUNC_DIV, :div) ||
637
+ eql_lit?(ECMA262::PUNC_MOD)
641
638
 
642
- if b = unary_exp(context)
639
+ if b = unary_exp(var_env)
643
640
  if punc == ECMA262::PUNC_MUL
644
641
  t = ECMA262::ExpMul.new(t, b)
645
642
  elsif punc == ECMA262::PUNC_DIV
@@ -648,7 +645,7 @@ module Minjs::Lex
648
645
  t = ECMA262::ExpMod.new(t, b)
649
646
  end
650
647
  else
651
- raise ParseError.new("unexpceted token", lex)
648
+ raise ParseError.new("unexpceted token", self)
652
649
  end
653
650
  end
654
651
  t
@@ -661,29 +658,29 @@ module Minjs::Lex
661
658
  # forward lexical parser position.
662
659
  # Otherwise return nil and position is not changed.
663
660
  #
664
- # @param context [Context] Lexical Environment
661
+ # @param var_env [EnvRecord] Lexical Environment
665
662
  #
666
663
  # @return [ECMA262::Base] expression
667
664
  #
668
665
  # @see ECMA262 11.6
669
- def additive_exp(context)
666
+ def additive_exp(var_env)
670
667
  # AdditiveExpression :
671
668
  # MultiplicativeExpression AdditiveExpression +
672
669
  # MultiplicativeExpression AdditiveExpression -
673
670
  # MultiplicativeExpression
674
- a = multiplicative_exp(context)
671
+ a = multiplicative_exp(var_env)
675
672
  return nil if !a
676
673
 
677
674
  t = a
678
- while punc = lex.eql_lit?(ECMA262::PUNC_ADD) || lex.eql_lit?(ECMA262::PUNC_SUB)
679
- if b = multiplicative_exp(context)
675
+ while punc = eql_lit?(ECMA262::PUNC_ADD) || eql_lit?(ECMA262::PUNC_SUB)
676
+ if b = multiplicative_exp(var_env)
680
677
  if punc == ECMA262::PUNC_ADD
681
678
  t = ECMA262::ExpAdd.new(t, b)
682
679
  else
683
680
  t = ECMA262::ExpSub.new(t, b)
684
681
  end
685
682
  else
686
- raise ParseError.new("unexpceted token", lex)
683
+ raise ParseError.new("unexpceted token", self)
687
684
  end
688
685
  end
689
686
  t
@@ -695,20 +692,20 @@ module Minjs::Lex
695
692
  # forward lexical parser position.
696
693
  # Otherwise return nil and position is not changed.
697
694
  #
698
- # @param context [Context] Lexical Environment
695
+ # @param var_env [EnvRecord] Lexical Environment
699
696
  # @option options :no_in [Boolean] If set, the parser interpret as RelationExpressionNoIn
700
697
  # @return [ECMA262::Base] expression
701
698
  #
702
699
  # see ECMA262 11.8
703
- def shift_exp(context)
704
- a = additive_exp(context)
700
+ def shift_exp(var_env)
701
+ a = additive_exp(var_env)
705
702
  return nil if !a
706
703
 
707
704
  t = a
708
- while punc = lex.eql_lit?(ECMA262::PUNC_LSHIFT) ||
709
- lex.eql_lit?(ECMA262::PUNC_RSHIFT) ||
710
- lex.eql_lit?(ECMA262::PUNC_URSHIFT)
711
- if b = additive_exp(context)
705
+ while punc = eql_lit?(ECMA262::PUNC_LSHIFT) ||
706
+ eql_lit?(ECMA262::PUNC_RSHIFT) ||
707
+ eql_lit?(ECMA262::PUNC_URSHIFT)
708
+ if b = additive_exp(var_env)
712
709
  if punc == ECMA262::PUNC_LSHIFT
713
710
  t = ECMA262::ExpLShift.new(t, b)
714
711
  elsif punc == ECMA262::PUNC_RSHIFT
@@ -717,7 +714,7 @@ module Minjs::Lex
717
714
  t = ECMA262::ExpURShift.new(t, b)
718
715
  end
719
716
  else
720
- raise ParseError.new("unexpceted token", lex)
717
+ raise ParseError.new("unexpceted token", self)
721
718
  end
722
719
  end
723
720
  t
@@ -729,12 +726,12 @@ module Minjs::Lex
729
726
  # forward lexical parser position.
730
727
  # Otherwise return nil and position is not changed.
731
728
  #
732
- # @param context [Context] Lexical Environment
729
+ # @param var_env [EnvRecord] Lexical Environment
733
730
  # @option options :no_in [Boolean] If set, the parser interpret as RelationExpressionNoIn
734
731
  # @return [ECMA262::Base] expression
735
732
  #
736
733
  # see ECMA262 11.8
737
- def relational_exp(context, options)
734
+ def relational_exp(var_env, options)
738
735
  #RelationalExpression :
739
736
  # ShiftExpression
740
737
  # RelationalExpression < ShiftExpression
@@ -743,14 +740,14 @@ module Minjs::Lex
743
740
  # RelationalExpression >= ShiftExpression
744
741
  # RelationalExpression instanceof ShiftExpression
745
742
  # RelationalExpression in ShiftExpression
746
- a = shift_exp(context)
743
+ a = shift_exp(var_env)
747
744
  return nil if !a
748
745
 
749
746
  t = a
750
- while (punc = lex.eql_lit?(ECMA262::PUNC_LT) || lex.eql_lit?(ECMA262::PUNC_GT) ||
751
- lex.eql_lit?(ECMA262::PUNC_LTEQ) || lex.eql_lit?(ECMA262::PUNC_GTEQ) ||
752
- lex.eql_lit?(ECMA262::ID_INSTANCEOF) || (!options[:no_in] && lex.eql_lit?(ECMA262::ID_IN)))
753
- if b = shift_exp(context)
747
+ while (punc = eql_lit?(ECMA262::PUNC_LT) || eql_lit?(ECMA262::PUNC_GT) ||
748
+ eql_lit?(ECMA262::PUNC_LTEQ) || eql_lit?(ECMA262::PUNC_GTEQ) ||
749
+ eql_lit?(ECMA262::ID_INSTANCEOF) || (!options[:no_in] && eql_lit?(ECMA262::ID_IN)))
750
+ if b = shift_exp(var_env)
754
751
  if punc == ECMA262::PUNC_LT
755
752
  t = ECMA262::ExpLt.new(t, b)
756
753
  elsif punc == ECMA262::PUNC_GT
@@ -766,7 +763,7 @@ module Minjs::Lex
766
763
  else
767
764
  end
768
765
  else
769
- raise ParseError.new("unexpceted token", lex)
766
+ raise ParseError.new("unexpceted token", self)
770
767
  end
771
768
  end
772
769
  t
@@ -778,22 +775,22 @@ module Minjs::Lex
778
775
  # forward lexical parser position.
779
776
  # Otherwise return nil and position is not changed.
780
777
  #
781
- # @param context [Context] Lexical Environment
778
+ # @param var_env [EnvRecord] Lexical Environment
782
779
  # @option options :no_in [Boolean] If set, the parser interpret as RelationExpressionNoIn
783
780
  #
784
781
  # @return [ECMA262::Base] expression
785
782
  #
786
783
  # @see ECMA262 11.9
787
- def equality_exp(context, options)
788
- a = relational_exp(context, options)
784
+ def equality_exp(var_env, options)
785
+ a = relational_exp(var_env, options)
789
786
  return nil if !a
790
787
 
791
788
  t = a
792
- while punc = lex.eql_lit?(ECMA262::PUNC_EQ) ||
793
- lex.eql_lit?(ECMA262::PUNC_NEQ) ||
794
- lex.eql_lit?(ECMA262::PUNC_SEQ) ||
795
- lex.eql_lit?(ECMA262::PUNC_SNEQ)
796
- if b = relational_exp(context, options)
789
+ while punc = eql_lit?(ECMA262::PUNC_EQ) ||
790
+ eql_lit?(ECMA262::PUNC_NEQ) ||
791
+ eql_lit?(ECMA262::PUNC_SEQ) ||
792
+ eql_lit?(ECMA262::PUNC_SNEQ)
793
+ if b = relational_exp(var_env, options)
797
794
  if punc == ECMA262::PUNC_EQ
798
795
  t = ECMA262::ExpEq.new(t, b)
799
796
  elsif punc == ECMA262::PUNC_NEQ
@@ -804,7 +801,7 @@ module Minjs::Lex
804
801
  t = ECMA262::ExpStrictNotEq.new(t, b)
805
802
  end
806
803
  else
807
- raise ParseError.new("unexpceted token", lex)
804
+ raise ParseError.new("unexpceted token", self)
808
805
  end
809
806
  end
810
807
  t
@@ -817,22 +814,22 @@ module Minjs::Lex
817
814
  # forward lexical parser position.
818
815
  # Otherwise return nil and position is not changed.
819
816
  #
820
- # @param context [Context] Lexical Environment
817
+ # @param var_env [EnvRecord] Lexical Environment
821
818
  # @option options :no_in [Boolean] If set, the parser interpret as RelationExpressionNoIn
822
819
  #
823
820
  # @return [ECMA262::Base] expression
824
821
  #
825
822
  # @see ECMA262 11.10
826
- def bitwise_and_exp(context, options)
827
- a = equality_exp(context, options)
823
+ def bitwise_and_exp(var_env, options)
824
+ a = equality_exp(var_env, options)
828
825
  return nil if !a
829
826
 
830
827
  t = a
831
- while punc = lex.eql_lit?(ECMA262::PUNC_AND)
832
- if b = equality_exp(context, options)
828
+ while punc = eql_lit?(ECMA262::PUNC_AND)
829
+ if b = equality_exp(var_env, options)
833
830
  t = ECMA262::ExpAnd.new(t, b)
834
831
  else
835
- raise ParseError.new("unexpceted token", lex)
832
+ raise ParseError.new("unexpceted token", self)
836
833
  end
837
834
  end
838
835
  t
@@ -845,22 +842,22 @@ module Minjs::Lex
845
842
  # forward lexical parser position.
846
843
  # Otherwise return nil and position is not changed.
847
844
  #
848
- # @param context [Context] Lexical Environment
845
+ # @param var_env [EnvRecord] Lexical Environment
849
846
  # @option options :no_in [Boolean] If set, the parser interpret as RelationExpressionNoIn
850
847
  #
851
848
  # @return [ECMA262::Base] expression
852
849
  #
853
850
  # @see ECMA262 11.10
854
- def bitwise_xor_exp(context, options)
855
- a = bitwise_and_exp(context, options)
851
+ def bitwise_xor_exp(var_env, options)
852
+ a = bitwise_and_exp(var_env, options)
856
853
  return nil if !a
857
854
 
858
855
  t = a
859
- while punc = lex.eql_lit?(ECMA262::PUNC_XOR)
860
- if b = bitwise_and_exp(context, options)
856
+ while punc = eql_lit?(ECMA262::PUNC_XOR)
857
+ if b = bitwise_and_exp(var_env, options)
861
858
  t = ECMA262::ExpXor.new(t, b)
862
859
  else
863
- raise ParseError.new("unexpceted token", lex)
860
+ raise ParseError.new("unexpceted token", self)
864
861
  end
865
862
  end
866
863
 
@@ -874,22 +871,22 @@ module Minjs::Lex
874
871
  # forward lexical parser position.
875
872
  # Otherwise return nil and position is not changed.
876
873
  #
877
- # @param context [Context] Lexical Environment
874
+ # @param var_env [EnvRecord] Lexical Environment
878
875
  # @option options :no_in [Boolean] If set, the parser interpret as RelationExpressionNoIn
879
876
  #
880
877
  # @return [ECMA262::Base] expression
881
878
  #
882
879
  # @see ECMA262 11.10
883
- def bitwise_or_exp(context, options)
884
- a = bitwise_xor_exp(context, options)
880
+ def bitwise_or_exp(var_env, options)
881
+ a = bitwise_xor_exp(var_env, options)
885
882
  return nil if !a
886
883
 
887
884
  t = a
888
- while punc = lex.eql_lit?(ECMA262::PUNC_OR)
889
- if b = bitwise_xor_exp(context, options)
885
+ while punc = eql_lit?(ECMA262::PUNC_OR)
886
+ if b = bitwise_xor_exp(var_env, options)
890
887
  t = ECMA262::ExpOr.new(t, b)
891
888
  else
892
- raise ParseError.new("unexpceted token", lex)
889
+ raise ParseError.new("unexpceted token", self)
893
890
  end
894
891
  end
895
892
  t
@@ -902,21 +899,21 @@ module Minjs::Lex
902
899
  # forward lexical parser position.
903
900
  # Otherwise return nil and position is not changed.
904
901
  #
905
- # @param context [Context] Lexical Environment
902
+ # @param var_env [EnvRecord] Lexical Environment
906
903
  # @return [ECMA262::Base] expression
907
904
  # @option options :no_in [Boolean] If set, the parser interpret as RelationExpressionNoIn
908
905
  #
909
906
  # @see ECMA262 11.11
910
- def logical_and_exp(context, options)
911
- a = bitwise_or_exp(context, options)
907
+ def logical_and_exp(var_env, options)
908
+ a = bitwise_or_exp(var_env, options)
912
909
  return nil if !a
913
910
 
914
911
  t = a
915
- while punc = lex.eql_lit?(ECMA262::PUNC_LAND)
916
- if b = bitwise_or_exp(context, options)
912
+ while punc = eql_lit?(ECMA262::PUNC_LAND)
913
+ if b = bitwise_or_exp(var_env, options)
917
914
  t = ECMA262::ExpLogicalAnd.new(t, b)
918
915
  else
919
- raise ParseError.new("unexpceted token", lex)
916
+ raise ParseError.new("unexpceted token", self)
920
917
  end
921
918
  end
922
919
 
@@ -930,21 +927,21 @@ module Minjs::Lex
930
927
  # forward lexical parser position.
931
928
  # Otherwise return nil and position is not changed.
932
929
  #
933
- # @param context [Context] Lexical Environment
930
+ # @param var_env [EnvRecord] Lexical Environment
934
931
  # @return [ECMA262::Base] expression
935
932
  # @option options :no_in [Boolean] If set, the parser interpret as RelationExpressionNoIn
936
933
  #
937
934
  # @see ECMA262 11.12
938
- def logical_or_exp(context, options)
939
- a = logical_and_exp(context, options)
935
+ def logical_or_exp(var_env, options)
936
+ a = logical_and_exp(var_env, options)
940
937
  return nil if !a
941
938
 
942
939
  t = a
943
- while punc = lex.eql_lit?(ECMA262::PUNC_LOR)
944
- if b = logical_and_exp(context, options)
940
+ while punc = eql_lit?(ECMA262::PUNC_LOR)
941
+ if b = logical_and_exp(var_env, options)
945
942
  t = ECMA262::ExpLogicalOr.new(t, b)
946
943
  else
947
- raise ParseError.new("unexpceted token", lex)
944
+ raise ParseError.new("unexpceted token", self)
948
945
  end
949
946
  end
950
947
 
@@ -957,20 +954,20 @@ module Minjs::Lex
957
954
  # forward lexical parser position.
958
955
  # Otherwise return nil and position is not changed.
959
956
  #
960
- # @param context [Context] Lexical Environment
957
+ # @param var_env [EnvRecord] Lexical Environment
961
958
  #
962
959
  # @return [ECMA262::Base] expression
963
960
  #
964
961
  # @see ECMA262 11.12
965
- def cond_exp(context, options)
966
- a = logical_or_exp(context, options)
962
+ def cond_exp(var_env, options)
963
+ a = logical_or_exp(var_env, options)
967
964
  return nil if !a
968
965
 
969
- if lex.eql_lit?(ECMA262::PUNC_CONDIF)
970
- if b=assignment_exp(context, options) and lex.eql_lit?(ECMA262::PUNC_COLON) and c=assignment_exp(context, options)
966
+ if eql_lit?(ECMA262::PUNC_CONDIF)
967
+ if b=assignment_exp(var_env, options) and eql_lit?(ECMA262::PUNC_COLON) and c=assignment_exp(var_env, options)
971
968
  ECMA262::ExpCond.new(a, b, c)
972
969
  else
973
- raise ParseError.new("unexpceted token", lex)
970
+ raise ParseError.new("unexpceted token", self)
974
971
  end
975
972
  else
976
973
  a
@@ -983,25 +980,25 @@ module Minjs::Lex
983
980
  # forward lexical parser position.
984
981
  # Otherwise return nil and position is not changed.
985
982
  #
986
- # @param context [Context] Lexical Environment
983
+ # @param var_env [EnvRecord] Lexical Environment
987
984
  # @option options :no_in [Boolean] If set, the parser interpret as RelationExpressionNoIn
988
985
  #
989
986
  # @see ECMA262 11.13
990
- def assignment_exp(context, options)
987
+ def assignment_exp(var_env, options)
991
988
  # AssignmentExpression :
992
989
  # ConditionalExpression
993
990
  # LeftHandSideExpression = AssignmentExpression
994
991
  # LeftHandSideExpression AssignmentOperator AssignmentExpression
995
992
  @logger.debug "*** assignment_exp"
996
993
 
997
- t = cond_exp(context, options)
994
+ t = cond_exp(var_env, options)
998
995
  return nil if t.nil?
999
996
 
1000
997
  if !t.left_hand_side_exp?
1001
998
  return t
1002
999
  end
1003
1000
  left_hand = t
1004
- punc = lex.peek_lit(:div)
1001
+ punc = peek_lit(:div)
1005
1002
  if punc == ECMA262::PUNC_ASSIGN ||
1006
1003
  punc == ECMA262::PUNC_DIVASSIGN ||
1007
1004
  punc == ECMA262::PUNC_MULASSIGN ||
@@ -1014,8 +1011,8 @@ module Minjs::Lex
1014
1011
  punc == ECMA262::PUNC_ANDASSIGN ||
1015
1012
  punc == ECMA262::PUNC_ORASSIGN ||
1016
1013
  punc == ECMA262::PUNC_XORASSIGN
1017
- lex.fwd_after_peek
1018
- if b = assignment_exp(context, options)
1014
+ fwd_after_peek
1015
+ if b = assignment_exp(var_env, options)
1019
1016
  case punc
1020
1017
  when ECMA262::PUNC_ASSIGN
1021
1018
  ECMA262::ExpAssign.new(left_hand, b)
@@ -1045,7 +1042,7 @@ module Minjs::Lex
1045
1042
  raise "internal error"
1046
1043
  end
1047
1044
  else
1048
- raise ParseError.new("unexpceted token", lex)
1045
+ raise ParseError.new("unexpceted token", self)
1049
1046
  end
1050
1047
  else
1051
1048
  @logger.debug {
@@ -1062,25 +1059,25 @@ module Minjs::Lex
1062
1059
  # forward lexical parser position.
1063
1060
  # Otherwise return nil and position is not changed.
1064
1061
  #
1065
- # @param context [Context] Lexical Environment
1062
+ # @param var_env [EnvRecord] Lexical Environment
1066
1063
  # @option options :no_in [Boolean] If set, the parser interpret as RelationExpressionNoIn
1067
1064
  #
1068
1065
  # @return [ECMA262::Base] expression
1069
1066
  #
1070
1067
  # @see ECMA262 11.14
1071
- def exp(context, options)
1068
+ def exp(var_env, options)
1072
1069
  # Expression :
1073
1070
  # AssignmentExpression
1074
1071
  # Expression , AssignmentExpression
1075
1072
  @logger.debug "*** expression"
1076
1073
 
1077
- t = assignment_exp(context, options)
1074
+ t = assignment_exp(var_env, options)
1078
1075
  return nil if t.nil?
1079
- while punc = lex.eql_lit?(ECMA262::PUNC_COMMA)
1080
- if b = assignment_exp(context, options)
1076
+ while punc = eql_lit?(ECMA262::PUNC_COMMA)
1077
+ if b = assignment_exp(var_env, options)
1081
1078
  t = ECMA262::ExpComma.new(t, b)
1082
1079
  else
1083
- raise ParseError.new("unexpceted token", lex)
1080
+ raise ParseError.new("unexpceted token", self)
1084
1081
  end
1085
1082
  end
1086
1083
  @logger.debug{