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.

APPENDIX E. ANTLR GRAMMAR<br />

}<br />

: ’ . ’ { _ttype = DOT; }<br />

|<br />

(<br />

’ 0 ’<br />

// s p e c i a l case f o r j u s t ’ 0 ’<br />

|<br />

( ’ 1 ’ . . ’ 9 ’ ) ( ’ 0 ’ . . ’ 9 ’ ) ∗<br />

// non−zero decimal<br />

)<br />

( ( ’ . ’ ( ’ 0 ’ . . ’ 9 ’ )+) =><br />

( ’ . ’ ( ’ 0 ’ . . ’ 9 ’ )+)<br />

{_ttype = REAL_LITERAL; }<br />

) ?<br />

;<br />

IDENT<br />

options { t e s t L i t e r a l s=true ; }<br />

: ( ’ a ’ . . ’ z ’ | ’A ’ . . ’Z ’ )<br />

( ’ a ’ . . ’ z ’ | ’A ’ . . ’Z ’ | ’_ ’ | ’ 0 ’ . . ’ 9 ’ ) ∗<br />

;<br />

WS<br />

: ( ’ ’<br />

| ’ \ r ’ ’ \n ’ { newline ( ) ; }<br />

| ’ \n ’ { newline ( ) ; }<br />

| ’ \ t ’<br />

)<br />

{ $setType ( Token . SKIP) ; }<br />

;<br />

// m u l t i p l e −l i n e comments<br />

ML_COMMENT<br />

: "/∗"<br />

(<br />

/∗<br />

’\ r ’ ’ \ n ’ can be matched in one a l t e r n a t i v e or by matching<br />

’\ r ’ in one i t e r a t i o n and ’\ n ’ in another . I am t r y i n g to<br />

handle any f l a v o r o f newline t h a t comes in , but the language<br />

t h a t a l l o w s both "\ r \n " and "\ r " and "\n" to a l l be v a l i d<br />

newline i s ambiguous . Consequently , the r e s u l t i n g grammar<br />

must be ambiguous . I ’m s h u t t i n g t h i s warning o f f .<br />

∗/<br />

options {<br />

generateAmbigWarnings=f a l s e ;<br />

}<br />

:<br />

{ LA( 2 ) != ’ / ’ } ? ’ ∗ ’<br />

| ’ \ r ’ ’ \n ’ { newline ( ) ; }<br />

506

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

Saved successfully!

Ooh no, something went wrong!