@@ -75,7 +75,7 @@ returns [spec]
7575
7676
7777type_spec_array [ block]
78- : # (ARRAY_DECLARATOR type_spec_array[block])
78+ : # (ad0: ARRAY_DECLARATOR type_spec_array[block])
7979 | spec = type[ block]
8080 ;
8181
@@ -89,15 +89,15 @@ returns [typ]
8989
9090builtin_type [ block]
9191returns [ typ]
92- : " void" { typ = " None" }
93- | " boolean" { typ = " bool" }
94- | " byte" { typ = " str" }
95- | " char" { typ = " str" }
96- | " short" { typ = " int" }
97- | " int" { typ = " int" }
98- | " float" { typ = " float" }
99- | " long" { typ = " long" }
100- | " double" { typ = " float" }
92+ : " void" { typ = " None" }
93+ | " boolean" { typ = " bool" }
94+ | " byte" { typ = " str" }
95+ | " char" { typ = " str" }
96+ | " short" { typ = " int" }
97+ | " int" { typ = " int" }
98+ | " float" { typ = " float" }
99+ | " long" { typ = " long" }
100+ | " double" { typ = " float" }
101101 ;
102102
103103
@@ -186,7 +186,10 @@ method_decl [block]
186186 modifiers[ meth]
187187 typ = type_spec[ meth]
188188 method_head[ meth]
189- ) { meth.type = typ}
189+ )
190+ {
191+ meth.type = typ
192+ }
190193 ;
191194
192195
@@ -231,7 +234,7 @@ variable_def [block]
231234
232235
233236parameter_def [ meth, add= True]
234- : # (PARAMETER_DEF
237+ : # (pd0: PARAMETER_DEF
235238 modifiers[ meth]
236239 ptype = type_spec[ meth]
237240 ident = identifier[ meth]
@@ -321,9 +324,10 @@ returns [ident]
321324
322325
323326statement_list [ block]
324- : # (SLIST (statement[block])*)
327+ : # (SLIST (s1: statement[block])*)
325328 ;
326329
330+ // MARKER
327331
328332statement [ block]
329333 : typ = type_def[ block]
@@ -429,6 +433,7 @@ statement [block]
429433 }
430434
431435 | try_block[ block]
436+ | ctor_call[ block]
432437 | statement_list[ block]
433438 | EMPTY_STAT
434439 ;
@@ -637,39 +642,60 @@ primary_expr [block]
637642returns [ exp = block.missingValue]
638643 : i0: IDENT { exp = (" %s " , i0.getText())}
639644
640- | { x = " " }
645+ | {
646+ dotexpr = this0 = class0 = class1 = class2 = id0 = id1 = ar0 = typ = None
647+ index = None
648+ }
641649 # (DOT
642- (x = expr[ block]
643- (a : IDENT
650+ (dotexpr = expr[ block]
651+ (id0 : IDENT
644652 | index = array_index[ block]
645- | " this"
646- | a0 : " class"
647- | # ("new" k :IDENT el0=expr_list[block] )
653+ | this0 : " this"
654+ | class0 : " class"
655+ | # ("new" id1 :IDENT el0=expr_list[block] )
648656 | " super"
649657 )
650- | # (ARRAY_DECLARATOR type_spec_array[block])
651- | t = builtin_type[ block] (" class" )?
658+ | # (ar0:ARRAY_DECLARATOR type_spec_array[block])
659+ (class1: " class" )?
660+ | typ = builtin_type[ block] (class2: " class" )?
652661 )
653662 )
654663 {
655- if a:
656- exp = (" %s .%s " , (x, (" %s " , a.getText())))
664+ if id0:
665+ exp = (" %s .%s " , (dotexpr, (" %s " , id0.getText())))
666+ elif ar0:
667+ exp = (" %s " , " []" )
668+ if class1:
669+ exp = (" %s .__class__" , exp)
670+ elif typ:
671+ exp = (" %s " , typ)
672+ elif id1:
673+ el0 = el0 or " "
674+ exp = (" %s (%s )" , ((" %s " , id1.getText()), (" %s " , el0)))
675+ }
676+
677+ | index = array_index[ block]
678+ {
679+ exp = index
657680 }
658681
659- | index = array_index[ block] { exp = index}
660-
661- | # (METHOD_CALL pex = primary_expr[block] el44=expr_list[block])
682+ | # (METHOD_CALL pex = primary_expr[block] exl = expr_list[block])
662683 {
663- if el44 :
664- exp = (" %s (%s )" , (pex, el44 ))
684+ if exl :
685+ exp = (" %s (%s )" , (pex, exl ))
665686 else :
666687 exp = (" %s ()" , pex)
667688 }
668689
669- | call = ctor_call[ block] { exp = ( " %s " , call) }
690+ | ctor_call[ block]
670691
671- | # (TYPECAST type_cast = type_spec[block] cast_exp = expr[block])
672- { exp = (" %s " , cast_exp)}
692+ | # (TYPECAST
693+ type_cast = type_spec[ block]
694+ cast_exp = expr[ block]
695+ )
696+ {
697+ exp = (" %s " , cast_exp)
698+ }
673699
674700 | other_exp = new_expression[ block] { exp = (" %s " , other_exp)}
675701 | con = constant[ block] { exp = (" %s " , con)}
@@ -684,10 +710,11 @@ returns [exp = block.missingValue]
684710
685711
686712ctor_call [ block]
687- returns [ seq= ()]
688- : # (cn:CTOR_CALL seq=expr_list[block] )
713+ : # (cn:CTOR_CALL seq=expr_list[block, False] )
689714 {
690- print " #@#@@@" , cn
715+ name = block.parent.name
716+ call = (" super(%s , self).__init__(%s )" , ((" %s " , name), (" %s " , seq)))
717+ block.addSource(call)
691718 }
692719
693720 | # (SUPER_CTOR_CALL
0 commit comments