-
Notifications
You must be signed in to change notification settings - Fork 19
/
Eval.py
executable file
·4900 lines (3171 loc) · 138 KB
/
Eval.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# $ANTLR 3.4 Eval.g 2012-12-09 16:07:29
import sys
from antlr3 import *
from antlr3.tree import *
from antlr3.compat import set, frozenset
from engine import CpyBuilder
# for convenience in actions
HIDDEN = BaseRecognizer.HIDDEN
# token types
EOF=-1
T__68=68
T__69=69
T__70=70
T__71=71
T__72=72
T__73=73
T__74=74
T__75=75
T__76=76
T__77=77
T__78=78
T__79=79
T__80=80
T__81=81
T__82=82
T__83=83
T__84=84
T__85=85
T__86=86
T__87=87
T__88=88
T__89=89
T__90=90
T__91=91
T__92=92
T__93=93
T__94=94
T__95=95
T__96=96
T__97=97
T__98=98
T__99=99
T__100=100
T__101=101
T__102=102
T__103=103
T__104=104
T__105=105
T__106=106
T__107=107
T__108=108
T__109=109
T__110=110
T__111=111
T__112=112
T__113=113
T__114=114
T__115=115
T__116=116
T__117=117
T__118=118
T__119=119
T__120=120
T__121=121
T__122=122
T__123=123
T__124=124
T__125=125
T__126=126
T__127=127
T__128=128
T__129=129
T__130=130
T__131=131
T__132=132
T__133=133
T__134=134
T__135=135
T__136=136
ALPHA=4
ARRAY=5
ASSIGN=6
BLOCK=7
BOOL=8
BREAK=9
CALL=10
CASE=11
CATCH=12
CLASS=13
COMMENT=14
CONSTRUCTOR=15
CONTINUE=16
DEFAULT=17
DIGIT=18
DOUBLE_QUOTE_CHARS=19
DO_WHILE=20
EACH=21
EACH_VAL=22
ELSE=23
ELSE_IF=24
EMPTY_LINE=25
EXEC_LIST=26
EXEC_STMT=27
EXPR_LIST=28
FINALLY=29
FLOAT=30
FOR=31
FOREACH=32
FUNCTION=33
ID=34
ID_LIST=35
IF=36
IMPORT=37
INDEX=38
INT=39
LINECOMMENT=40
MEMBER=41
MODULE=42
NEGATIVE=43
NEW=44
NEWLINE=45
NOP=46
NULL=47
OBJECT=48
OP_ASSIGN=49
PARAMS=50
POST_DEC=51
POST_INC=52
PRE_DEC=53
PRE_INC=54
PRINT=55
PRINTF=56
RETURN=57
SINGLE_QUOTE_CHARS=58
SLICE=59
SPRINTF=60
STRING=61
SWITCH=62
THROW=63
TRY=64
VAR=65
WHILE=66
WS=67
# token names
tokenNames = [
"<invalid>", "<EOR>", "<DOWN>", "<UP>",
"ALPHA", "ARRAY", "ASSIGN", "BLOCK", "BOOL", "BREAK", "CALL", "CASE",
"CATCH", "CLASS", "COMMENT", "CONSTRUCTOR", "CONTINUE", "DEFAULT", "DIGIT",
"DOUBLE_QUOTE_CHARS", "DO_WHILE", "EACH", "EACH_VAL", "ELSE", "ELSE_IF",
"EMPTY_LINE", "EXEC_LIST", "EXEC_STMT", "EXPR_LIST", "FINALLY", "FLOAT",
"FOR", "FOREACH", "FUNCTION", "ID", "ID_LIST", "IF", "IMPORT", "INDEX",
"INT", "LINECOMMENT", "MEMBER", "MODULE", "NEGATIVE", "NEW", "NEWLINE",
"NOP", "NULL", "OBJECT", "OP_ASSIGN", "PARAMS", "POST_DEC", "POST_INC",
"PRE_DEC", "PRE_INC", "PRINT", "PRINTF", "RETURN", "SINGLE_QUOTE_CHARS",
"SLICE", "SPRINTF", "STRING", "SWITCH", "THROW", "TRY", "VAR", "WHILE",
"WS", "'!'", "'!='", "'%'", "'%='", "'&&'", "'&'", "'&='", "'('", "')'",
"'*'", "'*='", "'+'", "'++'", "'+='", "','", "'-'", "'--'", "'-='",
"'.'", "'.*'", "'..'", "'/'", "'/='", "':'", "';'", "'<'", "'<='", "'='",
"'=='", "'=>'", "'>'", "'>='", "'['", "']'", "'^'", "'^='", "'as'",
"'break'", "'case'", "'catch'", "'class'", "'continue'", "'default'",
"'do'", "'else'", "'extends'", "'finally'", "'for'", "'foreach'", "'function'",
"'if'", "'import'", "'init'", "'new'", "'print'", "'printf'", "'public'",
"'return'", "'sprintf'", "'static'", "'switch'", "'throw'", "'try'",
"'while'", "'{'", "'|'", "'|='", "'||'", "'}'"
]
class Eval(TreeParser):
grammarFileName = "Eval.g"
api_version = 1
tokenNames = tokenNames
def __init__(self, input, state=None, *args, **kwargs):
if state is None:
state = RecognizerSharedState()
super(Eval, self).__init__(input, state, *args, **kwargs)
self.dfa4 = self.DFA4(
self, 4,
eot = self.DFA4_eot,
eof = self.DFA4_eof,
min = self.DFA4_min,
max = self.DFA4_max,
accept = self.DFA4_accept,
special = self.DFA4_special,
transition = self.DFA4_transition
)
self.delegates = []
# $ANTLR start "prog"
# Eval.g:21:1: prog[cpy] : ( stmt )* ;
def prog(self, cpy):
self.cpy = cpy
try:
try:
# Eval.g:28:2: ( ( stmt )* )
# Eval.g:28:4: ( stmt )*
pass
# Eval.g:28:4: ( stmt )*
while True: #loop1
alt1 = 2
LA1_0 = self.input.LA(1)
if (LA1_0 == BREAK or LA1_0 == CLASS or LA1_0 == CONTINUE or LA1_0 == DO_WHILE or LA1_0 == EXEC_STMT or (FOR <= LA1_0 <= FUNCTION) or (IF <= LA1_0 <= IMPORT) or (PRINT <= LA1_0 <= RETURN) or (SWITCH <= LA1_0 <= TRY) or LA1_0 == WHILE) :
alt1 = 1
if alt1 == 1:
# Eval.g:28:4: stmt
pass
self._state.following.append(self.FOLLOW_stmt_in_prog69)
self.stmt()
self._state.following.pop()
else:
break #loop1
#action start
self.cpy.close()
#action end
except RecognitionException, re:
self.reportError(re)
self.recover(self.input, re)
finally:
pass
return
# $ANTLR end "prog"
# $ANTLR start "stmt"
# Eval.g:31:1: stmt : ( import_stmt | exec_stmt | print_stmt | printf_stmt | break_stmt | continue_stmt | return_stmt | if_stmt | while_stmt | do_while_stmt | switch_stmt | throw_stmt | try_stmt | func_decl | class_decl | for_stmt | foreach_stmt );
def stmt(self, ):
try:
try:
# Eval.g:32:2: ( import_stmt | exec_stmt | print_stmt | printf_stmt | break_stmt | continue_stmt | return_stmt | if_stmt | while_stmt | do_while_stmt | switch_stmt | throw_stmt | try_stmt | func_decl | class_decl | for_stmt | foreach_stmt )
alt2 = 17
LA2 = self.input.LA(1)
if LA2 == IMPORT:
alt2 = 1
elif LA2 == EXEC_STMT:
alt2 = 2
elif LA2 == PRINT:
alt2 = 3
elif LA2 == PRINTF:
alt2 = 4
elif LA2 == BREAK:
alt2 = 5
elif LA2 == CONTINUE:
alt2 = 6
elif LA2 == RETURN:
alt2 = 7
elif LA2 == IF:
alt2 = 8
elif LA2 == WHILE:
alt2 = 9
elif LA2 == DO_WHILE:
alt2 = 10
elif LA2 == SWITCH:
alt2 = 11
elif LA2 == THROW:
alt2 = 12
elif LA2 == TRY:
alt2 = 13
elif LA2 == FUNCTION:
alt2 = 14
elif LA2 == CLASS:
alt2 = 15
elif LA2 == FOR:
alt2 = 16
elif LA2 == FOREACH:
alt2 = 17
else:
nvae = NoViableAltException("", 2, 0, self.input)
raise nvae
if alt2 == 1:
# Eval.g:32:4: import_stmt
pass
self._state.following.append(self.FOLLOW_import_stmt_in_stmt81)
self.import_stmt()
self._state.following.pop()
elif alt2 == 2:
# Eval.g:33:4: exec_stmt
pass
self._state.following.append(self.FOLLOW_exec_stmt_in_stmt86)
self.exec_stmt()
self._state.following.pop()
elif alt2 == 3:
# Eval.g:34:4: print_stmt
pass
self._state.following.append(self.FOLLOW_print_stmt_in_stmt91)
self.print_stmt()
self._state.following.pop()
elif alt2 == 4:
# Eval.g:34:17: printf_stmt
pass
self._state.following.append(self.FOLLOW_printf_stmt_in_stmt95)
self.printf_stmt()
self._state.following.pop()
elif alt2 == 5:
# Eval.g:35:4: break_stmt
pass
self._state.following.append(self.FOLLOW_break_stmt_in_stmt100)
self.break_stmt()
self._state.following.pop()
elif alt2 == 6:
# Eval.g:36:4: continue_stmt
pass
self._state.following.append(self.FOLLOW_continue_stmt_in_stmt105)
self.continue_stmt()
self._state.following.pop()
elif alt2 == 7:
# Eval.g:37:4: return_stmt
pass
self._state.following.append(self.FOLLOW_return_stmt_in_stmt110)
self.return_stmt()
self._state.following.pop()
elif alt2 == 8:
# Eval.g:38:4: if_stmt
pass
self._state.following.append(self.FOLLOW_if_stmt_in_stmt115)
self.if_stmt()
self._state.following.pop()
elif alt2 == 9:
# Eval.g:39:4: while_stmt
pass
self._state.following.append(self.FOLLOW_while_stmt_in_stmt120)
self.while_stmt()
self._state.following.pop()
elif alt2 == 10:
# Eval.g:40:4: do_while_stmt
pass
self._state.following.append(self.FOLLOW_do_while_stmt_in_stmt125)
self.do_while_stmt()
self._state.following.pop()
elif alt2 == 11:
# Eval.g:41:4: switch_stmt
pass
self._state.following.append(self.FOLLOW_switch_stmt_in_stmt130)
self.switch_stmt()
self._state.following.pop()
elif alt2 == 12:
# Eval.g:42:4: throw_stmt
pass
self._state.following.append(self.FOLLOW_throw_stmt_in_stmt135)
self.throw_stmt()
self._state.following.pop()
elif alt2 == 13:
# Eval.g:43:4: try_stmt
pass
self._state.following.append(self.FOLLOW_try_stmt_in_stmt140)
self.try_stmt()
self._state.following.pop()
elif alt2 == 14:
# Eval.g:44:4: func_decl
pass
self._state.following.append(self.FOLLOW_func_decl_in_stmt145)
self.func_decl()
self._state.following.pop()
elif alt2 == 15:
# Eval.g:45:4: class_decl
pass
self._state.following.append(self.FOLLOW_class_decl_in_stmt150)
self.class_decl()
self._state.following.pop()
elif alt2 == 16:
# Eval.g:46:4: for_stmt
pass
self._state.following.append(self.FOLLOW_for_stmt_in_stmt155)
self.for_stmt()
self._state.following.pop()
elif alt2 == 17:
# Eval.g:47:4: foreach_stmt
pass
self._state.following.append(self.FOLLOW_foreach_stmt_in_stmt160)
self.foreach_stmt()
self._state.following.pop()
except RecognitionException, re:
self.reportError(re)
self.recover(self.input, re)
finally:
pass
return
# $ANTLR end "stmt"
# $ANTLR start "block"
# Eval.g:52:1: block : ^( BLOCK ( stmt )* ) ;
def block(self, ):
self.cpy.block_enter()
try:
try:
# Eval.g:59:2: ( ^( BLOCK ( stmt )* ) )
# Eval.g:59:4: ^( BLOCK ( stmt )* )
pass
self.match(self.input, BLOCK, self.FOLLOW_BLOCK_in_block185)
if self.input.LA(1) == DOWN:
self.match(self.input, DOWN, None)
# Eval.g:59:12: ( stmt )*
while True: #loop3
alt3 = 2
LA3_0 = self.input.LA(1)
if (LA3_0 == BREAK or LA3_0 == CLASS or LA3_0 == CONTINUE or LA3_0 == DO_WHILE or LA3_0 == EXEC_STMT or (FOR <= LA3_0 <= FUNCTION) or (IF <= LA3_0 <= IMPORT) or (PRINT <= LA3_0 <= RETURN) or (SWITCH <= LA3_0 <= TRY) or LA3_0 == WHILE) :
alt3 = 1
if alt3 == 1:
# Eval.g:59:12: stmt
pass
self._state.following.append(self.FOLLOW_stmt_in_block187)
self.stmt()
self._state.following.pop()
else:
break #loop3
self.match(self.input, UP, None)
#action start
self.cpy.block_leave()
#action end
except RecognitionException, re:
self.reportError(re)
self.recover(self.input, re)
finally:
pass
return
# $ANTLR end "block"
# $ANTLR start "import_stmt"
# Eval.g:62:1: import_stmt : ^( IMPORT (a= module |b= module '.*' )+ ) ;
def import_stmt(self, ):
a = None
b = None
try:
try:
# Eval.g:63:2: ( ^( IMPORT (a= module |b= module '.*' )+ ) )
# Eval.g:63:4: ^( IMPORT (a= module |b= module '.*' )+ )
pass
self.match(self.input, IMPORT, self.FOLLOW_IMPORT_in_import_stmt201)
self.match(self.input, DOWN, None)
# Eval.g:64:3: (a= module |b= module '.*' )+
cnt4 = 0
while True: #loop4
alt4 = 3
alt4 = self.dfa4.predict(self.input)
if alt4 == 1:
# Eval.g:64:5: a= module
pass
self._state.following.append(self.FOLLOW_module_in_import_stmt209)
a = self.module()
self._state.following.pop()
#action start
self.cpy.op_import(a, None)
#action end
elif alt4 == 2:
# Eval.g:66:5: b= module '.*'
pass
self._state.following.append(self.FOLLOW_module_in_import_stmt222)
b = self.module()
self._state.following.pop()
self.match(self.input, 87, self.FOLLOW_87_in_import_stmt224)
#action start
self.cpy.op_import(b, '*')
#action end
else:
if cnt4 >= 1:
break #loop4
eee = EarlyExitException(4, self.input)
raise eee
cnt4 += 1
self.match(self.input, UP, None)
except RecognitionException, re:
self.reportError(re)
self.recover(self.input, re)
finally:
pass
return
# $ANTLR end "import_stmt"
# $ANTLR start "exec_stmt"
# Eval.g:72:1: exec_stmt : ^( EXEC_STMT exec_list ) ;
def exec_stmt(self, ):
exec_list1 = None
try:
try:
# Eval.g:73:2: ( ^( EXEC_STMT exec_list ) )
# Eval.g:73:4: ^( EXEC_STMT exec_list )
pass
self.match(self.input, EXEC_STMT, self.FOLLOW_EXEC_STMT_in_exec_stmt250)
self.match(self.input, DOWN, None)
self._state.following.append(self.FOLLOW_exec_list_in_exec_stmt252)
exec_list1 = self.exec_list()
self._state.following.pop()
self.match(self.input, UP, None)
#action start
self.cpy.stmt(exec_list1)
#action end
except RecognitionException, re:
self.reportError(re)
self.recover(self.input, re)
finally:
pass
return
# $ANTLR end "exec_stmt"
# $ANTLR start "exec_expr"
# Eval.g:76:1: exec_expr returns [text] : ( member_expr | ^( ASSIGN member_expr op= ( '=' | '+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '^=' | '|=' ) expr ) | ^( POST_INC member_expr ) | ^( POST_DEC member_expr ) | ^( PRE_INC member_expr ) | ^( PRE_DEC member_expr ) );
def exec_expr(self, ):
text = None
op = None
member_expr2 = None
member_expr3 = None
expr4 = None
member_expr5 = None
member_expr6 = None
member_expr7 = None
member_expr8 = None
try:
try:
# Eval.g:77:2: ( member_expr | ^( ASSIGN member_expr op= ( '=' | '+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '^=' | '|=' ) expr ) | ^( POST_INC member_expr ) | ^( POST_DEC member_expr ) | ^( PRE_INC member_expr ) | ^( PRE_DEC member_expr ) )
alt5 = 6
LA5 = self.input.LA(1)
if LA5 == MEMBER:
alt5 = 1
elif LA5 == ASSIGN:
alt5 = 2
elif LA5 == POST_INC:
alt5 = 3
elif LA5 == POST_DEC:
alt5 = 4
elif LA5 == PRE_INC:
alt5 = 5
elif LA5 == PRE_DEC:
alt5 = 6
else:
nvae = NoViableAltException("", 5, 0, self.input)
raise nvae
if alt5 == 1:
# Eval.g:77:4: member_expr
pass
self._state.following.append(self.FOLLOW_member_expr_in_exec_expr270)
member_expr2 = self.member_expr()
self._state.following.pop()
#action start
text = member_expr2
#action end
elif alt5 == 2:
# Eval.g:79:4: ^( ASSIGN member_expr op= ( '=' | '+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '^=' | '|=' ) expr )
pass
self.match(self.input, ASSIGN, self.FOLLOW_ASSIGN_in_exec_expr280)
self.match(self.input, DOWN, None)
self._state.following.append(self.FOLLOW_member_expr_in_exec_expr282)
member_expr3 = self.member_expr()
self._state.following.pop()
op = self.input.LT(1)
if self.input.LA(1) == 71 or self.input.LA(1) == 74 or self.input.LA(1) == 78 or self.input.LA(1) == 81 or self.input.LA(1) == 85 or self.input.LA(1) == 90 or self.input.LA(1) == 95 or self.input.LA(1) == 103 or self.input.LA(1) == 134:
self.input.consume()
self._state.errorRecovery = False
else:
mse = MismatchedSetException(None, self.input)
raise mse
self._state.following.append(self.FOLLOW_expr_in_exec_expr306)
expr4 = self.expr()
self._state.following.pop()
self.match(self.input, UP, None)
#action start
text = self.cpy.op_assign(member_expr3, expr4, op.text)
#action end
elif alt5 == 3:
# Eval.g:81:4: ^( POST_INC member_expr )
pass
self.match(self.input, POST_INC, self.FOLLOW_POST_INC_in_exec_expr317)
self.match(self.input, DOWN, None)
self._state.following.append(self.FOLLOW_member_expr_in_exec_expr319)
member_expr5 = self.member_expr()
self._state.following.pop()
self.match(self.input, UP, None)
#action start
text = self.cpy.op_inc(member_expr5)
#action end
elif alt5 == 4:
# Eval.g:83:4: ^( POST_DEC member_expr )
pass
self.match(self.input, POST_DEC, self.FOLLOW_POST_DEC_in_exec_expr330)
self.match(self.input, DOWN, None)
self._state.following.append(self.FOLLOW_member_expr_in_exec_expr332)
member_expr6 = self.member_expr()
self._state.following.pop()
self.match(self.input, UP, None)
#action start
text = self.cpy.op_dec(member_expr6)
#action end
elif alt5 == 5:
# Eval.g:85:4: ^( PRE_INC member_expr )
pass
self.match(self.input, PRE_INC, self.FOLLOW_PRE_INC_in_exec_expr343)
self.match(self.input, DOWN, None)
self._state.following.append(self.FOLLOW_member_expr_in_exec_expr345)
member_expr7 = self.member_expr()
self._state.following.pop()
self.match(self.input, UP, None)
#action start
text = self.cpy.op_inc(member_expr7)
#action end
elif alt5 == 6:
# Eval.g:87:4: ^( PRE_DEC member_expr )
pass
self.match(self.input, PRE_DEC, self.FOLLOW_PRE_DEC_in_exec_expr356)
self.match(self.input, DOWN, None)
self._state.following.append(self.FOLLOW_member_expr_in_exec_expr358)
member_expr8 = self.member_expr()
self._state.following.pop()
self.match(self.input, UP, None)
#action start
text = self.cpy.op_dec(member_expr8)
#action end
except RecognitionException, re:
self.reportError(re)
self.recover(self.input, re)
finally:
pass
return text
# $ANTLR end "exec_expr"
# $ANTLR start "exec_list"
# Eval.g:90:1: exec_list returns [text] : ^( EXEC_LIST ( exec_expr )+ ) ;
def exec_list(self, ):
text = None
exec_expr9 = None
ps = []
try:
try:
# Eval.g:92:2: ( ^( EXEC_LIST ( exec_expr )+ ) )
# Eval.g:92:4: ^( EXEC_LIST ( exec_expr )+ )
pass
self.match(self.input, EXEC_LIST, self.FOLLOW_EXEC_LIST_in_exec_list382)
self.match(self.input, DOWN, None)
# Eval.g:92:16: ( exec_expr )+
cnt6 = 0
while True: #loop6
alt6 = 2
LA6_0 = self.input.LA(1)
if (LA6_0 == ASSIGN or LA6_0 == MEMBER or (POST_DEC <= LA6_0 <= PRE_INC)) :
alt6 = 1
if alt6 == 1:
# Eval.g:92:17: exec_expr
pass
self._state.following.append(self.FOLLOW_exec_expr_in_exec_list385)
exec_expr9 = self.exec_expr()
self._state.following.pop()
#action start
ps.append(exec_expr9)
#action end
else:
if cnt6 >= 1:
break #loop6
eee = EarlyExitException(6, self.input)
raise eee
cnt6 += 1
self.match(self.input, UP, None)
#action start
text = ', '.join(ps)
#action end
except RecognitionException, re:
self.reportError(re)
self.recover(self.input, re)
finally:
pass
return text
# $ANTLR end "exec_list"
# $ANTLR start "printf_stmt"
# Eval.g:96:1: printf_stmt : ^( PRINTF expr ( expr_list )? ) ;
def printf_stmt(self, ):
expr10 = None
expr_list11 = None
try:
try:
# Eval.g:97:2: ( ^( PRINTF expr ( expr_list )? ) )
# Eval.g:97:4: ^( PRINTF expr ( expr_list )? )
pass
self.match(self.input, PRINTF, self.FOLLOW_PRINTF_in_printf_stmt408)
self.match(self.input, DOWN, None)
self._state.following.append(self.FOLLOW_expr_in_printf_stmt410)
expr10 = self.expr()
self._state.following.pop()
# Eval.g:97:18: ( expr_list )?
alt7 = 2
LA7_0 = self.input.LA(1)
if (LA7_0 == EXPR_LIST) :
alt7 = 1
if alt7 == 1:
# Eval.g:97:18: expr_list
pass
self._state.following.append(self.FOLLOW_expr_list_in_printf_stmt412)
expr_list11 = self.expr_list()
self._state.following.pop()
self.match(self.input, UP, None)
#action start
self.cpy.op_printf(expr10, expr_list11)
#action end
except RecognitionException, re:
self.reportError(re)
self.recover(self.input, re)
finally:
pass
return
# $ANTLR end "printf_stmt"
# $ANTLR start "print_stmt"
# Eval.g:100:1: print_stmt : ^( PRINT expr_list ) ;
def print_stmt(self, ):
expr_list12 = None
try:
try:
# Eval.g:101:2: ( ^( PRINT expr_list ) )
# Eval.g:101:4: ^( PRINT expr_list )
pass