26.09.2013 Views

Transformation of Applicative Specifications into Imperative ...

Transformation of Applicative Specifications into Imperative ...

Transformation of Applicative Specifications into Imperative ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 9. IMPLEMENTATION OF THE TRANSFORMER<br />

which recognizes patterns. The actual grammar is placed between the outermost<br />

: and ;. The pattern can be a value literal pattern which consists <strong>of</strong><br />

a value literal, it can be a name pattern which consists <strong>of</strong> a value name, it<br />

can be a record pattern which is <strong>of</strong> the form name(pattern, ..., pattern), it<br />

can be a wild card pattern which consists <strong>of</strong> an underscore and so on.<br />

Example 9.1 – Example <strong>of</strong> the ANTLR grammar<br />

RSL Syntax:<br />

pattern ::= value_literal |<br />

pure_value_name |<br />

record_pattern |<br />

wildcard_name |<br />

record_pattern ::= pure_value_name(pattern−list)<br />

ANTLR grammar:<br />

pattern returns [ Pattern p ] {<br />

p = null ;<br />

Make_ValueOrVariableName vovn = null ;<br />

Make_ValueOrVariableName vovn2 = null ;<br />

Make_ValueOrVariableName vovn3 = null ;<br />

Pattern ip = null ;<br />

V a l u e L i t e r a l v l = null ;<br />

RSLListDefault i n n e r P a t t e r n L i s t =<br />

new RSLListDefault() ;<br />

L i s t P a t t e r n lp = null ;<br />

}<br />

: v l = v a l u e _ l i t e r a l<br />

{p = new V a l u e L i t e r a l P a t t e r n ( v l ) ; }<br />

|<br />

vovn = name<br />

{p = new NamePattern (<br />

vovn . value_or_variable_name ( ) . id ( ) ,<br />

new NoOptionalId ( ) ) ; }<br />

|<br />

vovn = name LPAREN ip = pattern<br />

{ i n n e r P a t t e r n L i s t . g e t L i s t ( ) . add ( ip ) ; }<br />

(<br />

COMMA ip = pattern<br />

{ i n n e r P a t t e r n L i s t . g e t L i s t ( ) . add ( ip ) ; }<br />

102

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

Saved successfully!

Ooh no, something went wrong!