Transformation of Applicative Specifications into Imperative ...

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

26.09.2013 Views

APPENDIX F. SOURCE CODE } r e s u l t . append ( " ) " ) ; public void v i s i t M a k e L i s t P a t t e r n L e t ( MakeListPatternLet l i s t P a t t e r n ) { l i s t P a t t e r n . l i s t _ p a t t e r n ( ) . accept ( this ) ; } public void v i s i t M a k e L i s t P a t t e r n ( MakeListPattern l i s t P a t t e r n ) { l i s t P a t t e r n . l i s t _ p a t t e r n ( ) . accept ( this ) ; } public void visitMake_EnumeratedListPattern ( Make_EnumeratedListPattern enumListPattern ) { enumListPattern . enum_list_pattern ( ) . accept ( this ) ; } public void v i s i t C o n c a t e n a t e d L i s t P a t t e r n ( ConcatenatedListPattern c o n c a t L i s t P a t t e r n ) { c o n c a t L i s t P a t t e r n . c_enum_list_pattern ( ) . accept ( this ) ; r e s u l t . append ( " ^ " ) ; c o n c a t L i s t P a t t e r n . c_inner_pattern ( ) . accept ( this ) ; } public void visitEnumeratedListPattern ( EnumeratedListPattern enumListPattern ) { r e s u l t . append ( "" ) ; } public void v i s i t I n n e r P a t t e r n L i s t ( I n n e r P a t t e r n L i s t i n n e r P a t t e r n L i s t ) { for ( Pattern pattern : i n n e r P a t t e r n L i s t . p a t t e r n _ l i s t ( ) . g e t L i s t ( ) ) { pattern . accept ( this ) ; r e s u l t . append ( " , " ) ; } i f ( i n n e r P a t t e r n L i s t . p a t t e r n _ l i s t ( ) . l e n ( ) > 0) { r e s u l t . d e l e t e ( r e s u l t . length ( ) − 2 , r e s u l t . length ( ) ) ; } } public void v i s i t N o I n n e r P a t t e r n ( NoInnerPattern noInnerPattern ) {} public void v i s i t V a l u e L i t e r a l P a t t e r n ( V a l u e L i t e r a l P a t t e r n pattern ) { pattern . v a l u e _ l i t e r a l ( ) . accept ( this ) ; 550

} F.2. VISITOR MODULES public void visitNamePattern ( NamePattern pattern ) { pattern . id ( ) . accept ( this ) ; } public void v i s i t W i l d c a r d P a t t e r n ( WildcardPattern pattern ) { r e s u l t . append ( "_" ) ; } public void v i s i t P r o d u c t P a t t e r n ( ProductPattern pattern ) { r e s u l t . append ( " ( " ) ; for ( Pattern p : pattern . p_inner_pattern_list ( ) . g e t L i s t ( ) ) { p . accept ( this ) ; r e s u l t . append ( " , " ) ; } i f ( pattern . p_inner_pattern_list ( ) . l e n ( ) > 0) { r e s u l t . d e l e t e ( r e s u l t . l ength ( ) − 2 , r e s u l t . length ( ) ) ; } r e s u l t . append ( " ) " ) ; } public void v i s i t R e c o r d P a t t e r n ( RecordPattern pattern ) { pattern . value_or_variable_name ( ) . accept ( this ) ; r e s u l t . append ( " ( " ) ; for ( Pattern p : pattern . i n n e r _ p a t t e r n _ l i s t ( ) . g e t L i s t ( ) ) { p . accept ( this ) ; r e s u l t . append ( " , " ) ; } i f ( pattern . i n n e r _ p a t t e r n _ l i s t ( ) . l e n ( ) > 0) { r e s u l t . d e l e t e ( r e s u l t . l ength ( ) − 2 , r e s u l t . length ( ) ) ; } r e s u l t . append ( " ) " ) ; } public void v i s i t I f E x p r ( IfExpr ifExpr ) { r e s u l t . append ( " i f " ) ; ifExpr . c o n d i t i o n ( ) . accept ( this ) ; r e s u l t . append ( " then " ) ; ifExpr . i f _ c a s e ( ) . accept ( this ) ; for ( E l s i f e l s i f : ifExpr . e l s i f _ l i s t ( ) . g e t L i s t ( ) ) { e l s i f . accept ( this ) ; } r e s u l t . append ( " e l s e " ) ; ifExpr . e l s e _ c a s e ( ) . accept ( this ) ; r e s u l t . append ( " end" ) ; } public void v i s i t E l s i f ( E l s i f e l s i f ) { 551

APPENDIX F. SOURCE CODE<br />

}<br />

r e s u l t . append ( " ) " ) ;<br />

public void v i s i t M a k e L i s t P a t t e r n L e t ( MakeListPatternLet l i s t P a t t e r n )<br />

{<br />

l i s t P a t t e r n . l i s t _ p a t t e r n ( ) . accept ( this ) ;<br />

}<br />

public void v i s i t M a k e L i s t P a t t e r n ( MakeListPattern l i s t P a t t e r n ) {<br />

l i s t P a t t e r n . l i s t _ p a t t e r n ( ) . accept ( this ) ;<br />

}<br />

public void visitMake_EnumeratedListPattern (<br />

Make_EnumeratedListPattern<br />

enumListPattern ) {<br />

enumListPattern . enum_list_pattern ( ) . accept ( this ) ;<br />

}<br />

public void v i s i t C o n c a t e n a t e d L i s t P a t t e r n ( ConcatenatedListPattern<br />

c o n c a t L i s t P a t t e r n ) {<br />

c o n c a t L i s t P a t t e r n . c_enum_list_pattern ( ) . accept ( this ) ;<br />

r e s u l t . append ( " ^ " ) ;<br />

c o n c a t L i s t P a t t e r n . c_inner_pattern ( ) . accept ( this ) ;<br />

}<br />

public void visitEnumeratedListPattern ( EnumeratedListPattern<br />

enumListPattern ) {<br />

r e s u l t . append ( "" ) ;<br />

}<br />

public void v i s i t I n n e r P a t t e r n L i s t ( I n n e r P a t t e r n L i s t<br />

i n n e r P a t t e r n L i s t ) {<br />

for ( Pattern pattern :<br />

i n n e r P a t t e r n L i s t . p a t t e r n _ l i s t ( ) . g e t L i s t ( ) ) {<br />

pattern . accept ( this ) ;<br />

r e s u l t . append ( " , " ) ;<br />

}<br />

i f ( i n n e r P a t t e r n L i s t . p a t t e r n _ l i s t ( ) . l e n ( ) > 0) {<br />

r e s u l t . d e l e t e ( r e s u l t . length ( ) − 2 , r e s u l t . length ( ) ) ;<br />

}<br />

}<br />

public void v i s i t N o I n n e r P a t t e r n ( NoInnerPattern noInnerPattern ) {}<br />

public void v i s i t V a l u e L i t e r a l P a t t e r n ( V a l u e L i t e r a l P a t t e r n<br />

pattern ) {<br />

pattern . v a l u e _ l i t e r a l ( ) . accept ( this ) ;<br />

550

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

Saved successfully!

Ooh no, something went wrong!