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

now = null ;<br />

}<br />

: var = q u a l i f i e d _ i d<br />

{now = new Name(new ValueOrVariableName ( var ) ) ; }<br />

| UNDERSCORE { now = new Wildcard ( ) ; }<br />

;<br />

short_record_def returns [ ShortRecordDef srd ] {<br />

srd = null ;<br />

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

RSLListDefault componentKindString = null ;<br />

}<br />

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

componentKindString = component_kind_string<br />

{ srd =<br />

new ShortRecordDef ( i d e n t i f i e r , componentKindString ) ; }<br />

;<br />

component_kind_list returns<br />

[ RSLListDefault componentKindList ] {<br />

componentKindList = new RSLListDefault() ;<br />

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

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

TypeExpr typeExpr = null ;<br />

TypeExpr typeExpr2 = null ;<br />

}<br />

: ( i d e n t i f i e r 1 = id COLON) ?<br />

typeExpr = type_expr<br />

(LT TOTALARROW i d e n t i f i e r 2 = id ) ?<br />

{<br />

componentKindList . g e t L i s t ( ) . add (<br />

new ComponentKind (<br />

( i d e n t i f i e r 1 ! = null ?<br />

new Destructor ( i d e n t i f i e r 1 ) :<br />

new NoDestructor ( ) ) ,<br />

typeExpr ,<br />

( i d e n t i f i e r 2 ! = null ?<br />

new Reconstructor ( i d e n t i f i e r 2 ) :<br />

new NoReconstructor ( ) ) ) ) ;<br />

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

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

}<br />

(<br />

COMMA<br />

( i d e n t i f i e r 1 = id COLON) ?<br />

typeExpr2 = type_expr<br />

(LT TOTALARROW i d e n t i f i e r 2 = id ) ?<br />

{<br />

481

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

Saved successfully!

Ooh no, something went wrong!