minjs 0.1.2

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.
@@ -0,0 +1,714 @@
1
+ module Minjs
2
+ module Exp
3
+ #
4
+ # Primary Expressions
5
+ # 11.1
6
+ #
7
+ def primary_exp(lex, context, options)
8
+ STDERR.puts "*** primary_exp" if @debug
9
+ lex.debug_lit if @debug
10
+ #STDERR.puts caller if @debug
11
+ #this
12
+ if lex.match_lit(ECMA262::ID_THIS)
13
+ STDERR.puts "*** primary_exp => this" if @debug
14
+ return ECMA262::ID_THIS
15
+ end
16
+ # (exp)
17
+ if lex.match_lit(ECMA262::PUNC_LPARENTHESIS)
18
+ if a=exp(lex, context, options) and lex.match_lit(ECMA262::PUNC_RPARENTHESIS)
19
+ STDERR.puts "*** primary_exp => ()" if @debug
20
+ return ECMA262::ExpParen.new(a)
21
+ else
22
+ raise 'error'
23
+ end
24
+ end
25
+
26
+ # identifier || literal || array_literal || object_literal
27
+ t = lex.eval_lit {
28
+ identifier(lex, context)
29
+ } || lex.eval_lit {
30
+ literal(lex, context)
31
+ } || lex.eval_lit {
32
+ array_literal(lex, context, options)
33
+ } || lex.eval_lit {
34
+ object_literal(lex, context, options)
35
+ }
36
+ STDERR.puts "*** primary_exp => #{t}" if @debug
37
+ t
38
+ end
39
+
40
+ #
41
+ # 11.1.2
42
+ #
43
+ def identifier(lex, context)
44
+ lex.eval_lit {
45
+ if (a = lex.fwd_lit).kind_of? ECMA262::IdentifierName and !a.reserved?
46
+ a.context = context
47
+ a
48
+ else
49
+ nil
50
+ end
51
+ }
52
+ end
53
+
54
+ #
55
+ # 11.1.4
56
+ #
57
+ def array_literal(lex, context, options)
58
+ return nil unless lex.match_lit(ECMA262::PUNC_LSQBRAC)
59
+ t = []
60
+ lex.eval_lit {
61
+ while true
62
+ if lex.match_lit(ECMA262::PUNC_COMMA)
63
+ t.push(nil)
64
+ elsif lex.match_lit(ECMA262::PUNC_RSQBRAC)
65
+ break
66
+ elsif a = assignment_exp(lex, context, {})
67
+ t.push(a)
68
+ lex.match_lit(ECMA262::PUNC_COMMA)
69
+ else
70
+ raise ParseError.new("no `]' end of array", lex)
71
+ end
72
+ end
73
+ ECMA262::ECMA262Array.new(t)
74
+ }
75
+ end
76
+ #
77
+ # 11.1.5
78
+ #
79
+ def object_literal(lex, context, options)
80
+ return nil unless lex.match_lit(ECMA262::PUNC_LCURLYBRAC)
81
+ lex.eval_lit {
82
+ if lex.match_lit(ECMA262::PUNC_RCURLYBRAC)
83
+ next ECMA262::ECMA262Object.new([])
84
+ end
85
+ if h=property_name_and_value_list(lex, context, options)
86
+ ECMA262::ECMA262Object.new(h)
87
+ else
88
+ raise ParseError.new("no `}' end of object", lex)
89
+ end
90
+ }
91
+ end
92
+
93
+ #
94
+ # name: exp
95
+ # get name(){funcbody}
96
+ # set name(args){funcbody}
97
+ #
98
+ def property_name_and_value_list(lex, context, options)
99
+ lex.eval_lit{
100
+ h = []
101
+ while !lex.eof?
102
+ if lex.match_lit(ECMA262::PUNC_RCURLYBRAC)
103
+ break
104
+ end
105
+ lex.eval_lit{
106
+ a=property_name(lex, context) and lex.match_lit(ECMA262::PUNC_COLON) and b=assignment_exp(lex, context, options)
107
+ h.push([a, b])
108
+ }
109
+ # or lex.eval_lit{
110
+ # if lex.match_lit(ECMA262::ID_GET) and a=property_name(lex, context) and lex.match_lit(ECMA262::PUNC_LPARENTHESIS) and lex.match_lit(ECMA262::PUNC_RPARENTHESIS) and lex.match_lit(ECMA262::PUNC_LCURLYBRAC) and func_body(lex, context) and lex.match_lit(ECMA262::PUNC_RCURLYBRAC)
111
+ # h[a] = "getter" #TODO
112
+ # elsif lex.match_lit(ECMA262::ID_SET) and a=property_name(lex, context) and lex.match_lit(ECMA262::PUNC_LPARENTHESIS) and property_set_parameter_list(lex, context) and lex.match_lit(ECMA262::PUNC_RPARENTHESIS) and lex.match_lit(ECMA262::PUNC_LCURLYBRAC) and func_body(lex, context) and lex.match_lit(ECMA262::PUNC_RCURLYBRAC)
113
+ # h[a] = "setter" #TODO
114
+ # else
115
+ # return nil
116
+ # end
117
+ # }
118
+
119
+ if lex.match_lit(ECMA262::PUNC_COMMA)
120
+ break if lex.match_lit(ECMA262::PUNC_RCURLYBRAC)
121
+ elsif lex.match_lit(ECMA262::PUNC_RCURLYBRAC)
122
+ break
123
+ else
124
+ raise ParseError.new("no `}' end of object", lex)
125
+ end
126
+ end
127
+ h
128
+ }
129
+ end
130
+
131
+ def property_name(lex, context)
132
+ lex.eval_lit {
133
+ a = lex.fwd_lit
134
+ if a.kind_of?(ECMA262::ECMA262String)
135
+ a
136
+ elsif a.kind_of?(ECMA262::IdentifierName)
137
+ ECMA262::ECMA262String.new(a.to_js)
138
+ elsif a.kind_of?(ECMA262::ECMA262Numeric)
139
+ a
140
+ else
141
+ raise ParseError.new("The Property name must be kind_of ItentiferName or String", lex)
142
+ end
143
+ }
144
+ end
145
+
146
+ def property_set_parameter_list(lex, context)
147
+ lex.eval_lit {
148
+ a = lex.fwd_lit
149
+ if a.kind_of?(ECMA262::IdentifierName) and !a.reserved?
150
+ a
151
+ else
152
+ nil
153
+ end
154
+ }
155
+ end
156
+
157
+ #
158
+ # 11.2
159
+ #
160
+ def left_hand_side_exp(lex, context, options)
161
+ STDERR.puts "*** left_hand_side_exp" if @debug
162
+ lex.debug_lit if @debug
163
+
164
+ t = lex.eval_lit{
165
+ call_exp(lex, context, options)
166
+ } || lex.eval_lit{
167
+ new_exp(lex, context, options)
168
+ }
169
+ STDERR.puts "*** left_hand_side_exp => #{t}" if @debug
170
+ t
171
+ end
172
+
173
+ def new_exp(lex, context, options)
174
+ lex.eval_lit{
175
+ if lex.match_lit(ECMA262::ID_NEW) and a=new_exp(lex, context, options)
176
+ ECMA262::ExpNew.new(a, nil)
177
+ else
178
+ nil
179
+ end
180
+ } or lex.eval_lit{
181
+ member_exp(lex, context, options)
182
+ }
183
+ end
184
+
185
+ #
186
+ # call
187
+ #
188
+ # member_exp arguments
189
+ #
190
+ # call_exp arguments
191
+ # call_exp [exp]
192
+ # call_exp . identifier_name
193
+ #
194
+ #
195
+ def call_exp(lex, context, options)
196
+ a = lex.eval_lit{
197
+ if f = member_exp(lex, context, options)
198
+ if b = arguments(lex, context, options)
199
+ ECMA262::ExpCall.new(f, b)
200
+ else
201
+ f
202
+ end
203
+ else
204
+ nil
205
+ end
206
+ }
207
+ return nil if a.nil?
208
+
209
+ t = a
210
+
211
+ lex.eval_lit{
212
+ while true
213
+ if b=arguments(lex, context, options)
214
+ t = ECMA262::ExpCall.new(t, b)
215
+ elsif lex.match_lit(ECMA262::PUNC_LSQBRAC) and b=exp(lex, context, options) and lex.match_lit(ECMA262::PUNC_RSQBRAC)
216
+ t = ECMA262::ExpPropBrac.new(t, b)
217
+ elsif lex.match_lit(ECMA262::PUNC_PERIOD) and (b=lex.fwd_lit()).kind_of?(ECMA262::IdentifierName)
218
+ t = ECMA262::ExpProp.new(t, b)
219
+ else
220
+ break
221
+ end
222
+ end
223
+ t
224
+ } or a
225
+ end
226
+
227
+ #
228
+ # member_exp
229
+ # primary_exp
230
+ # function_exp
231
+ # new member_exp arguments
232
+ #
233
+ # member_exp[exp]
234
+ # member_exp.identifier_name #prop(a,b)
235
+ #
236
+ def member_exp(lex, context, options)
237
+ a = lex.eval_lit {
238
+ primary_exp(lex, context, options)
239
+ } || lex.eval_lit {
240
+ func_exp(lex, context)
241
+ } || lex.eval_lit {
242
+ if lex.match_lit(ECMA262::ID_NEW) and a=member_exp(lex, context, options) and b=arguments(lex, context, options)
243
+ ECMA262::ExpNew.new(a, b)
244
+ else
245
+ nil
246
+ end
247
+ }
248
+ return nil if a.nil?
249
+
250
+ t = a
251
+
252
+ lex.eval_lit {
253
+ while true
254
+ if lex.match_lit(ECMA262::PUNC_LSQBRAC) and b=exp(lex, context, options) and lex.match_lit(ECMA262::PUNC_RSQBRAC)
255
+ t = ECMA262::ExpPropBrac.new(t, b)
256
+ elsif lex.match_lit(ECMA262::PUNC_PERIOD) and (b=lex.fwd_lit()).kind_of?(ECMA262::IdentifierName)
257
+ t = ECMA262::ExpProp.new(t, b)
258
+ else
259
+ break
260
+ end
261
+ end
262
+ t
263
+ } or a
264
+ end
265
+
266
+ def arguments(lex, context, options)
267
+ lex.eval_lit{
268
+ return nil if lex.match_lit(ECMA262::PUNC_LPARENTHESIS).nil?
269
+ next [] if lex.match_lit(ECMA262::PUNC_RPARENTHESIS)
270
+ args = []
271
+ while true
272
+ if t = assignment_exp(lex, context, options)
273
+ args.push(t)
274
+ else
275
+ return
276
+ end
277
+ if lex.match_lit(ECMA262::PUNC_COMMA)
278
+ ;
279
+ elsif lex.match_lit(ECMA262::PUNC_RPARENTHESIS)
280
+ break
281
+ else
282
+ return
283
+ end
284
+ end
285
+ args
286
+ }
287
+ end
288
+ #
289
+ # 11.3
290
+ #
291
+ def postfix_exp(lex, context, options)
292
+ STDERR.puts "*** postfix_exp" if @debug
293
+ lex.debug_lit if @debug
294
+
295
+ next_exp = :left_hand_side_exp
296
+ t = lex.eval_lit{
297
+ a = __send__(next_exp, lex, context, options)
298
+ return nil if a.nil?
299
+ if punc = (lex.match_lit(ECMA262::PUNC_INC) ||
300
+ lex.match_lit(ECMA262::PUNC_DEC))
301
+ if punc == ECMA262::PUNC_INC
302
+ ECMA262::ExpPostInc.new(a)
303
+ else
304
+ ECMA262::ExpPostDec.new(a)
305
+ end
306
+ else
307
+ a
308
+ end
309
+ }
310
+ STDERR.puts "*** postfix_exp => #{t}" if @debug
311
+ t
312
+ end
313
+
314
+ #
315
+ # 11.4
316
+ #
317
+ def unary_exp(lex, context, options)
318
+ next_exp = :postfix_exp
319
+ lex.eval_lit{
320
+ if punc = (lex.match_lit(ECMA262::ID_DELETE) ||
321
+ lex.match_lit(ECMA262::ID_VOID) ||
322
+ lex.match_lit(ECMA262::ID_TYPEOF) ||
323
+ lex.match_lit(ECMA262::PUNC_INC) ||
324
+ lex.match_lit(ECMA262::PUNC_DEC) ||
325
+ lex.match_lit(ECMA262::PUNC_ADD) ||
326
+ lex.match_lit(ECMA262::PUNC_SUB) ||
327
+ lex.match_lit(ECMA262::PUNC_NOT) ||
328
+ lex.match_lit(ECMA262::PUNC_LNOT)) and a = unary_exp(lex, context, options)
329
+ if punc.val == :delete
330
+ ECMA262::ExpDelete.new(a)
331
+ elsif punc.val == :void
332
+ ECMA262::ExpVoid.new(a)
333
+ elsif punc.val == :typeof
334
+ ECMA262::ExpTypeof.new(a)
335
+ elsif punc == ECMA262::PUNC_INC
336
+ ECMA262::ExpPreInc.new(a)
337
+ elsif punc == ECMA262::PUNC_DEC
338
+ ECMA262::ExpPreDec.new(a)
339
+ elsif punc == ECMA262::PUNC_ADD
340
+ ECMA262::ExpPositive.new(a)
341
+ elsif punc == ECMA262::PUNC_SUB
342
+ ECMA262::ExpNegative.new(a)
343
+ elsif punc == ECMA262::PUNC_NOT
344
+ ECMA262::ExpBitwiseNot.new(a)
345
+ elsif punc == ECMA262::PUNC_LNOT
346
+ ECMA262::ExpLogicalNot.new(a)
347
+ end
348
+ end
349
+ } || lex.eval_lit{
350
+ __send__(next_exp, lex, context, options)
351
+ }
352
+ end
353
+
354
+ #
355
+ # 11.5
356
+ #
357
+ def multiplicative_exp(lex, context, options)
358
+ next_exp = :unary_exp
359
+ lex.eval_lit {
360
+ a = __send__(next_exp, lex, context, options)
361
+ next nil if !a
362
+ t = a
363
+ while punc = lex.match_lit(ECMA262::PUNC_MUL) ||
364
+ lex.match_lit(ECMA262::PUNC_DIV, :hint => :div) ||
365
+ lex.match_lit(ECMA262::PUNC_MOD)
366
+
367
+ if b = __send__(next_exp, lex, context, options)
368
+ if punc == ECMA262::PUNC_MUL
369
+ t = ECMA262::ExpMul.new(t, b)
370
+ elsif punc == ECMA262::PUNC_DIV
371
+ t = ECMA262::ExpDiv.new(t, b)
372
+ else
373
+ t = ECMA262::ExpMod.new(t, b)
374
+ end
375
+ else
376
+ break
377
+ end
378
+ end
379
+ t
380
+ }
381
+ end
382
+
383
+ #
384
+ # 11.6
385
+ #
386
+ def additive_exp(lex, context, options)
387
+ next_exp = :multiplicative_exp
388
+ lex.eval_lit {
389
+ a = __send__(next_exp, lex, context, options)
390
+ next nil if !a
391
+
392
+ t = a
393
+ while punc = lex.match_lit(ECMA262::PUNC_ADD) || lex.match_lit(ECMA262::PUNC_SUB)
394
+ if b = __send__(next_exp, lex, context, options)
395
+ if punc == ECMA262::PUNC_ADD
396
+ t = ECMA262::ExpAdd.new(t, b)
397
+ else
398
+ t = ECMA262::ExpSub.new(t, b)
399
+ end
400
+ else
401
+ break
402
+ end
403
+ end
404
+
405
+ t
406
+ }
407
+ end
408
+ #
409
+ # 11.7
410
+ def shift_exp(lex, context, options)
411
+ next_exp = :additive_exp
412
+ lex.eval_lit {
413
+ a = __send__(next_exp, lex, context, options)
414
+ next nil if !a
415
+
416
+ t = a
417
+ while punc = lex.match_lit(ECMA262::PUNC_LSHIFT) ||
418
+ lex.match_lit(ECMA262::PUNC_RSHIFT) ||
419
+ lex.match_lit(ECMA262::PUNC_URSHIFT)
420
+ if b = __send__(next_exp, lex, context, options)
421
+ if punc == ECMA262::PUNC_LSHIFT
422
+ t = ECMA262::ExpLShift.new(t, b)
423
+ elsif punc == ECMA262::PUNC_RSHIFT
424
+ t = ECMA262::ExpRShift.new(t, b)
425
+ elsif punc == ECMA262::PUNC_URSHIFT
426
+ t = ECMA262::ExpURShift.new(t, b)
427
+ end
428
+ else
429
+ break
430
+ end
431
+ end
432
+ t
433
+ }
434
+ end
435
+ #
436
+ #
437
+ # 11.8
438
+ #
439
+ def relational_exp(lex, context, options)
440
+ next_exp = :shift_exp
441
+ lex.eval_lit {
442
+ a = __send__(next_exp, lex, context, options)
443
+ next nil if !a
444
+
445
+ t = a
446
+ while (punc = lex.match_lit(ECMA262::PUNC_LT) || lex.match_lit(ECMA262::PUNC_GT) ||
447
+ lex.match_lit(ECMA262::PUNC_LTEQ) || lex.match_lit(ECMA262::PUNC_GTEQ) ||
448
+ lex.match_lit(ECMA262::ID_INSTANCEOF) || lex.match_lit(ECMA262::ID_IN))
449
+ if b = __send__(next_exp, lex, context, options)
450
+ if punc == ECMA262::PUNC_LT
451
+ t = ECMA262::ExpLt.new(t, b)
452
+ elsif punc == ECMA262::PUNC_GT
453
+ t = ECMA262::ExpGt.new(t, b)
454
+ elsif punc == ECMA262::PUNC_LTEQ
455
+ t = ECMA262::ExpLtEq.new(t, b)
456
+ elsif punc == ECMA262::PUNC_GTEQ
457
+ t = ECMA262::ExpGtEq.new(t, b)
458
+ elsif punc.val == :instanceof
459
+ t = ECMA262::ExpInstanceOf.new(t, b)
460
+ elsif !options[:no_in] and punc.val == :in
461
+ t = ECMA262::ExpIn.new(t, b)
462
+ else
463
+ end
464
+ else
465
+ break
466
+ end
467
+ end
468
+
469
+ t
470
+ }
471
+ end
472
+ #
473
+ #
474
+ # 11.9
475
+ # a == b
476
+ # a != b
477
+ # a === b
478
+ # a !== b
479
+ #
480
+ def equality_exp(lex, context, options)
481
+ next_exp = :relational_exp
482
+ lex.eval_lit {
483
+ a = __send__(next_exp, lex, context, options)
484
+ next nil if !a
485
+
486
+ t = a
487
+ while punc = lex.match_lit(ECMA262::PUNC_EQ) ||
488
+ lex.match_lit(ECMA262::PUNC_NEQ) ||
489
+ lex.match_lit(ECMA262::PUNC_SEQ) ||
490
+ lex.match_lit(ECMA262::PUNC_SNEQ)
491
+ if b = __send__(next_exp, lex, context, options)
492
+ if punc == ECMA262::PUNC_EQ
493
+ t = ECMA262::ExpEq.new(t, b)
494
+ elsif punc == ECMA262::PUNC_NEQ
495
+ t = ECMA262::ExpNotEq.new(t, b)
496
+ elsif punc == ECMA262::PUNC_SEQ
497
+ t = ECMA262::ExpStrictEq.new(t, b)
498
+ elsif punc == ECMA262::PUNC_SNEQ
499
+ t = ECMA262::ExpStrictNotEq.new(t, b)
500
+ end
501
+ else
502
+ break
503
+ end
504
+ end
505
+
506
+ t
507
+ }
508
+ end
509
+
510
+ #
511
+ # 11.10
512
+ # a & b
513
+ #
514
+ def bitwise_and_exp(lex, context, options)
515
+ next_exp = :equality_exp
516
+ lex.eval_lit {
517
+ a = __send__(next_exp, lex, context, options)
518
+ next nil if !a
519
+
520
+ t = a
521
+ while punc = lex.match_lit(ECMA262::PUNC_AND)
522
+ if b = __send__(next_exp, lex, context, options)
523
+ t = ECMA262::ExpAnd.new(t, b)
524
+ else
525
+ break
526
+ end
527
+ end
528
+
529
+ t
530
+ }
531
+ end
532
+
533
+ #
534
+ # a ^ b
535
+ #
536
+ def bitwise_xor_exp(lex, context, options)
537
+ next_exp = :bitwise_and_exp
538
+ lex.eval_lit {
539
+ a = __send__(next_exp, lex, context, options)
540
+ next nil if !a
541
+
542
+ t = a
543
+ while punc = lex.match_lit(ECMA262::PUNC_XOR)
544
+ if b = __send__(next_exp, lex, context, options)
545
+ t = ECMA262::ExpXor.new(t, b)
546
+ else
547
+ break
548
+ end
549
+ end
550
+
551
+ t
552
+ }
553
+ end
554
+
555
+ #
556
+ # a | b
557
+ #
558
+ def bitwise_or_exp(lex, context, options)
559
+ next_exp = :bitwise_xor_exp
560
+ lex.eval_lit {
561
+ a = __send__(next_exp, lex, context, options)
562
+ next nil if !a
563
+
564
+ t = a
565
+ while punc = lex.match_lit(ECMA262::PUNC_OR)
566
+ if b = __send__(next_exp, lex, context, options)
567
+ t = ECMA262::ExpOr.new(t, b)
568
+ else
569
+ break
570
+ end
571
+ end
572
+
573
+ t
574
+ }
575
+ end
576
+ #
577
+ # 11.11
578
+ # a && b
579
+ #
580
+ def logical_and_exp(lex, context, options)
581
+ next_exp = :bitwise_or_exp
582
+ lex.eval_lit {
583
+ a = __send__(next_exp, lex, context, options)
584
+ next nil if !a
585
+
586
+ t = a
587
+ while punc = lex.match_lit(ECMA262::PUNC_LAND)
588
+ if b = __send__(next_exp, lex, context, options)
589
+ t = ECMA262::ExpLogicalAnd.new(t, b)
590
+ else
591
+ break
592
+ end
593
+ end
594
+
595
+ t
596
+ }
597
+ end
598
+
599
+ def logical_or_exp(lex, context, options)
600
+ next_exp = :logical_and_exp
601
+ lex.eval_lit {
602
+ a = __send__(next_exp, lex, context, options)
603
+ next nil if !a
604
+
605
+ t = a
606
+ while punc = lex.match_lit(ECMA262::PUNC_LOR)
607
+ if b = __send__(next_exp, lex, context, options)
608
+ t = ECMA262::ExpLogicalOr.new(t, b)
609
+ else
610
+ break
611
+ end
612
+ end
613
+
614
+ t
615
+ }
616
+ end
617
+ #
618
+ # 11.12
619
+ # a ? b : c
620
+ #
621
+ def cond_exp(lex, context, options)
622
+ t = lex.eval_lit {
623
+ a = logical_or_exp(lex, context, options)
624
+ next nil if !a
625
+
626
+ if lex.match_lit(ECMA262::PUNC_CONDIF) and b=assignment_exp(lex, context, options) and lex.match_lit(ECMA262::PUNC_CONDELSE) and c=assignment_exp(lex, context, options)
627
+ ECMA262::ExpCond.new(a, b, c)
628
+ else
629
+ a
630
+ end
631
+ }
632
+ t
633
+ end
634
+ #
635
+ #11.13
636
+ #
637
+ def assignment_exp(lex, context, options)
638
+ STDERR.puts "*** assignment_exp" if @debug
639
+ lex.debug_lit if @debug
640
+ left_hand = nil
641
+ t = cond_exp(lex, context, options)
642
+ return nil if t.nil?
643
+ lex.eval_lit {
644
+ left_hand = t
645
+ punc = lex.next_lit
646
+ if punc == ECMA262::PUNC_LET ||
647
+ punc == ECMA262::PUNC_DIVLET ||
648
+ punc == ECMA262::PUNC_MULLET ||
649
+ punc == ECMA262::PUNC_MODLET ||
650
+ punc == ECMA262::PUNC_ADDLET ||
651
+ punc == ECMA262::PUNC_SUBLET ||
652
+ punc == ECMA262::PUNC_LSHIFTLET ||
653
+ punc == ECMA262::PUNC_RSHIFTLET ||
654
+ punc == ECMA262::PUNC_URSHIFTLET ||
655
+ punc == ECMA262::PUNC_ANDLET ||
656
+ punc == ECMA262::PUNC_ORLET ||
657
+ punc == ECMA262::PUNC_XORLET
658
+ lex.fwd_lit
659
+ if b = assignment_exp(lex, context, options)
660
+ case punc
661
+ when ECMA262::PUNC_LET
662
+ ECMA262::ExpAssign.new(left_hand, b)
663
+ when ECMA262::PUNC_DIVLET
664
+ ECMA262::ExpDivAssign.new(left_hand, b)
665
+ when ECMA262::PUNC_MULLET
666
+ ECMA262::ExpMulAssign.new(left_hand, b)
667
+ when ECMA262::PUNC_MODLET
668
+ ECMA262::ExpModAssign.new(left_hand, b)
669
+ when ECMA262::PUNC_ADDLET
670
+ ECMA262::ExpAddAssign.new(left_hand, b)
671
+ when ECMA262::PUNC_SUBLET
672
+ ECMA262::ExpSubAssign.new(left_hand, b)
673
+ when ECMA262::PUNC_LSHIFTLET
674
+ ECMA262::ExpLShiftAssign.new(left_hand, b)
675
+ when ECMA262::PUNC_RSHIFTLET
676
+ ECMA262::ExpRShiftAssign.new(left_hand, b)
677
+ when ECMA262::PUNC_URSHIFTLET
678
+ ECMA262::ExpURShiftAssign.new(left_hand, b)
679
+ when ECMA262::PUNC_ANDLET
680
+ ECMA262::ExpAndAssign.new(left_hand, b)
681
+ when ECMA262::PUNC_ORLET
682
+ ECMA262::ExpOrAssign.new(left_hand, b)
683
+ when ECMA262::PUNC_XORLET
684
+ ECMA262::ExpXorAssign.new(left_hand, b)
685
+ else
686
+ raise "not implement"
687
+ end
688
+ else # some assignment operator presents but no assignment_expression => fail
689
+ return nil
690
+ end
691
+ else
692
+ t
693
+ end
694
+ }
695
+ end
696
+
697
+ #
698
+ # 11.14
699
+ #
700
+ def exp(lex, context, options)
701
+ lex.eval_lit{
702
+ t = assignment_exp(lex, context, {:hint => :regexp}.merge(options))
703
+ while punc = lex.match_lit(ECMA262::PUNC_COMMA)
704
+ if b = assignment_exp(lex,context, {:hint => :regexp}.merge(options))
705
+ t = ECMA262::ExpComma.new(t, b)
706
+ else
707
+ break
708
+ end
709
+ end
710
+ t
711
+ }
712
+ end
713
+ end
714
+ end