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 ; } ( componentKindList ) ) ; componentKindList = null ; } BAR 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 ( constructor , componentKindList ) ) ; componentKindList = null ; } } ) ∗ {vd = new VariantDef ( i d e n t i f i e r , v a r i a n t _ l i s t ) ; } union_def [ Id i d e n t i f i e r ] returns [ UnionDef ud ] { ud = null ; NameOrWildcard nw = null ; RSLListDefault nameOrWildcardList = new RSLListDefault() ; } : nw = name_or_wildcard { nameOrWildcardList . g e t L i s t ( ) . add (nw) ; } ( BAR nw = name_or_wildcard { nameOrWildcardList . g e t L i s t ( ) . add (nw) ; } ) ∗ {ud = new UnionDef ( i d e n t i f i e r , nameOrWildcardList ) ; } ; name_or_wildcard returns [ NameOrWildcard now ] { Id var = null ; 480

now = null ; } : var = q u a l i f i e d _ i d {now = new Name(new ValueOrVariableName ( var ) ) ; } | UNDERSCORE { now = new Wildcard ( ) ; } ; short_record_def returns [ ShortRecordDef srd ] { srd = null ; Id i d e n t i f i e r = null ; RSLListDefault componentKindString = null ; } : i d e n t i f i e r = id COLON COLON componentKindString = component_kind_string { srd = new ShortRecordDef ( i d e n t i f i e r , componentKindString ) ; } ; component_kind_list returns [ RSLListDefault componentKindList ] { componentKindList = new RSLListDefault() ; Id i d e n t i f i e r 1 = null ; Id i d e n t i f i e r 2 = null ; TypeExpr typeExpr = null ; TypeExpr typeExpr2 = null ; } : ( i d e n t i f i e r 1 = id COLON) ? typeExpr = type_expr (LT TOTALARROW i d e n t i f i e r 2 = id ) ? { componentKindList . g e t L i s t ( ) . add ( new ComponentKind ( ( i d e n t i f i e r 1 ! = null ? new Destructor ( i d e n t i f i e r 1 ) : new NoDestructor ( ) ) , typeExpr , ( i d e n t i f i e r 2 ! = null ? new Reconstructor ( i d e n t i f i e r 2 ) : new NoReconstructor ( ) ) ) ) ; i d e n t i f i e r 1 = null ; i d e n t i f i e r 2 = null ; } ( COMMA ( i d e n t i f i e r 1 = id COLON) ? typeExpr2 = type_expr (LT TOTALARROW i d e n t i f i e r 2 = id ) ? { 481

APPENDIX E. ANTLR GRAMMAR<br />

;<br />

}<br />

(<br />

componentKindList<br />

) ) ;<br />

componentKindList = null ;<br />

}<br />

BAR 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 />

constructor ,<br />

componentKindList<br />

) ) ;<br />

componentKindList = null ;<br />

}<br />

}<br />

) ∗<br />

{vd = new VariantDef ( i d e n t i f i e r , v a r i a n t _ l i s t ) ; }<br />

union_def [ Id i d e n t i f i e r ] returns [ UnionDef ud ] {<br />

ud = null ;<br />

NameOrWildcard nw = null ;<br />

RSLListDefault<br />

nameOrWildcardList =<br />

new RSLListDefault() ;<br />

}<br />

: nw = name_or_wildcard<br />

{ nameOrWildcardList . g e t L i s t ( ) . add (nw) ; }<br />

(<br />

BAR nw = name_or_wildcard<br />

{ nameOrWildcardList . g e t L i s t ( ) . add (nw) ; }<br />

) ∗<br />

{ud = new UnionDef ( i d e n t i f i e r , nameOrWildcardList ) ; }<br />

;<br />

name_or_wildcard returns [ NameOrWildcard now ] {<br />

Id var = null ;<br />

480

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

Saved successfully!

Ooh no, something went wrong!