Transformation of Applicative Specifications into Imperative ...

Transformation of Applicative Specifications into Imperative ... Transformation of Applicative Specifications into Imperative ...

26.09.2013 Views

APPENDIX E. ANTLR GRAMMAR ; d = d e c l { d e c l _ l i s t . g e t L i s t ( ) . add ( d ) ; } ) ∗ END {be = new BasicClassExpr ( d e c l _ l i s t ) ; } extending_class_expr returns [ ExtendingClassExpr ece ] { ece = null ; ClassExpr ce1 = null ; ClassExpr ce2 = null ; } : EXTEND ce1 = class_expr WITH ce2 = class_expr { ece = new ExtendingClassExpr ( ce1 , ce2 ) ; } ; scheme_instantiation returns [ SchemeInstantiation s i ] { s i = null ; Id i d e n t i f i e r = null ; } : i d e n t i f i e r = id { s i = new SchemeInstantiation ( i d e n t i f i e r ) ; } ; d e c l returns [ Decl d ] { d = null ; } : VALUE d = value_decl | TYPE d = type_decl | TEST_CASE d = t e s t _ d e c l ; //Type D e c l a r a t i o n type_decl returns [ TypeDecl td ] { td = null ; RSLListDefault type_def_list = new RSLListDefault() ; TypeDef def ; } : def = type_def { type_def_list . g e t L i s t ( ) . add ( def ) ; } ( COMMA def = type_def { type_def_list . g e t L i s t ( ) . add ( def ) ; } ) ∗ { td = new TypeDecl ( type_def_list ) ; } ; 478

type_def returns [ TypeDef td ] { td = null ; Id i d e n t i f i e r = null ; } : td = sort_def | td = variant_def | td = short_record_def | i d e n t i f i e r = id EQUAL td = abbreviation_def [ i d e n t i f i e r ] /∗ | td = union_def [ i d e n t i f i e r ] ) ∗/ ; sort_def returns [ SortDef sd ] { sd = null ; Id i d e n t i f i e r = null ; } : i d e n t i f i e r = id { sd = new SortDef ( i d e n t i f i e r ) ; } ; variant_def returns [ VariantDef vd ] { vd = null ; Id i d e n t i f i e r = null ; Id i d e n t i f i e r 2 = null ; Constructor c o n s t r u c t o r = null ; RSLListDefault v a r i a n t _ l i s t = new RSLListDefault() ; RSLListDefault componentKindList = null ; } : i d e n t i f i e r = id EQUALEQUAL i d e n t i f i e r 2 = id { c o n s t r u c t o r = new Constructor ( i d e n t i f i e r 2 ) ; } ( LPAREN componentKindList = component_kind_list RPAREN ) ? { i f ( componentKindList == null ) { v a r i a n t _ l i s t . g e t L i s t ( ) . add ( new Make_Constructor ( c o n s t r u c t o r ) ) ; } else { v a r i a n t _ l i s t . g e t L i s t ( ) . add ( new RecordVariant ( c o n s t r u c t o r , 479

type_def returns [ TypeDef td ] {<br />

td = null ;<br />

Id i d e n t i f i e r = null ;<br />

}<br />

: td = sort_def<br />

| td = variant_def<br />

| td = short_record_def<br />

| i d e n t i f i e r = id<br />

EQUAL td = abbreviation_def [ i d e n t i f i e r ]<br />

/∗ | td = union_def [ i d e n t i f i e r ] ) ∗/<br />

;<br />

sort_def returns [ SortDef sd ] {<br />

sd = null ;<br />

Id i d e n t i f i e r = null ;<br />

}<br />

: i d e n t i f i e r = id<br />

{ sd = new SortDef ( i d e n t i f i e r ) ; }<br />

;<br />

variant_def returns [ VariantDef vd ] {<br />

vd = null ;<br />

Id i d e n t i f i e r = null ;<br />

Id i d e n t i f i e r 2 = null ;<br />

Constructor c o n s t r u c t o r = null ;<br />

RSLListDefault<br />

v a r i a n t _ l i s t =<br />

new RSLListDefault() ;<br />

RSLListDefault componentKindList =<br />

null ;<br />

}<br />

: i d e n t i f i e r = id EQUALEQUAL<br />

i d e n t i f i e r 2 = id<br />

{ c o n s t r u c t o r = new Constructor ( i d e n t i f i e r 2 ) ; }<br />

(<br />

LPAREN<br />

componentKindList = component_kind_list<br />

RPAREN<br />

) ?<br />

{<br />

i f ( componentKindList == null ) {<br />

v a r i a n t _ l i s t . g e t L i s t ( ) . add (<br />

new Make_Constructor ( c o n s t r u c t o r ) ) ;<br />

}<br />

else {<br />

v a r i a n t _ l i s t . g e t L i s t ( ) . add (<br />

new RecordVariant (<br />

c o n s t r u c t o r ,<br />

479

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!