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 prod_binding returns [ Binding b ] { b = null ; Binding b1 = null ; RSLListDefault b i n d i n g _ l i s t = new RSLListDefault() ; } : LPAREN b1 = binding { b i n d i n g _ l i s t . g e t L i s t ( ) . add ( b1 ) ; } ( COMMA b1 = binding { b i n d i n g _ l i s t . g e t L i s t ( ) . add ( b1 ) ; } ) ∗ RPAREN {b = new Make_ProductBinding ( new ProductBinding ( b i n d i n g _ l i s t ) ) ; } ; // Test D e c l a r a t i o n s t e s t _ d e c l returns [ TestDecl td ] { td = null ; RSLListDefault t e s t _ d e f _ l i s t = new RSLListDefault() ; TestDef def ; } : def = test_def { t e s t _ d e f _ l i s t . g e t L i s t ( ) . add ( def ) ; } ( COMMA def = test_def { t e s t _ d e f _ l i s t . g e t L i s t ( ) . add ( def ) ; } ) ∗ { td = new TestDecl ( t e s t _ d e f _ l i s t ) ; } ; test_def returns [ TestCase td ] { td = null ; Id i d e n t i f i e r = null ; ValueExpr ve = null ; } : LBRACKET i d e n t i f i e r = id RBRACKET ve = value_expr { td = new TestCase ( i d e n t i f i e r , ve ) ; } ; //Type Expression type_expr returns [ TypeExpr te ] { te = null ; FunctionArrow f a = null ; TypeExpr te2 = null ; TypeExpr te3 = null ; ResultDesc rd = null ; } : te2 = type_expr_pr2 486

; ( ( | TOTALARROW { f a = new TOTAL_FUNCTION_ARROW( ) ; } PARTIAL TOTALARROW { f a = new PARTIAL_FUNCTION_ARROW( ) ; } ) rd = r e s u l t _ d e s c { te = new FunctionTypeExpr ( te2 , fa , rd ) ; } ) ? { i f ( te == null ) te = te2 ; } type_expr_pr2 returns [ TypeExpr te ] { te = null ; TypeExpr te2 = null ; TypeExpr te3 = null ; RSLListDefault typeExprList = new RSLListDefault() ; } : te2 = type_expr_pr1 { typeExprList . g e t L i s t ( ) . add ( te2 ) ; } ( CROSS te3 = type_expr_pr1 { typeExprList . g e t L i s t ( ) . add ( te3 ) ; } ) ∗ { i f ( te3 ! = null ) { te = new TypeExprProduct ( typeExprList ) ; } else { te = te2 ; } } ; type_expr_pr1 returns [ TypeExpr te ] { te = null ; TypeExpr te2 = null ; TypeExpr te3 = null ; SingleTyping s t = null ; ValueExpr ve = null ; } : te2 = type_expr_primary ( MINUS ( LIST 487

APPENDIX E. ANTLR GRAMMAR<br />

prod_binding returns [ Binding b ] {<br />

b = null ;<br />

Binding b1 = null ;<br />

RSLListDefault b i n d i n g _ l i s t =<br />

new RSLListDefault() ;<br />

}<br />

: LPAREN b1 = binding<br />

{ b i n d i n g _ l i s t . g e t L i s t ( ) . add ( b1 ) ; }<br />

(<br />

COMMA b1 = binding<br />

{ b i n d i n g _ l i s t . g e t L i s t ( ) . add ( b1 ) ; }<br />

) ∗<br />

RPAREN<br />

{b = new Make_ProductBinding (<br />

new ProductBinding ( b i n d i n g _ l i s t ) ) ; }<br />

;<br />

// Test D e c l a r a t i o n s<br />

t e s t _ d e c l returns [ TestDecl td ] {<br />

td = null ;<br />

RSLListDefault t e s t _ d e f _ l i s t =<br />

new RSLListDefault() ;<br />

TestDef def ;<br />

}<br />

: def = test_def { t e s t _ d e f _ l i s t . g e t L i s t ( ) . add ( def ) ; }<br />

(<br />

COMMA def = test_def<br />

{ t e s t _ d e f _ l i s t . g e t L i s t ( ) . add ( def ) ; }<br />

) ∗<br />

{ td = new TestDecl ( t e s t _ d e f _ l i s t ) ; }<br />

;<br />

test_def returns [ TestCase td ] {<br />

td = null ;<br />

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

ValueExpr ve = null ;<br />

}<br />

: LBRACKET i d e n t i f i e r = id RBRACKET ve = value_expr<br />

{ td = new TestCase ( i d e n t i f i e r , ve ) ; }<br />

;<br />

//Type Expression<br />

type_expr returns [ TypeExpr te ] {<br />

te = null ;<br />

FunctionArrow f a = null ;<br />

TypeExpr te2 = null ;<br />

TypeExpr te3 = null ;<br />

ResultDesc rd = null ; }<br />

: te2 = type_expr_pr2<br />

486

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

Saved successfully!

Ooh no, something went wrong!