source: trunk/yao/share/antlr-2.7.7/examples/java/parseBinary/data.g @ 1

Last change on this file since 1 was 1, checked in by lnalod, 15 years ago

Initial import of YAO sources

File size: 417 bytes
Line 
1class DataParser extends Parser;
2
3file:   (       sh:SHORT        {System.out.println(sh.getText());}
4                |       st:STRING       {System.out.println("\""+st.getText()+"\"");}
5                )+
6        ;
7
8class DataLexer extends Lexer;
9options {
10        charVocabulary = '\u0000'..'\u00FF';
11}
12
13SHORT
14        :       '\0' high:. lo:.
15                {
16                int v = (((int)high)<<8) + lo;
17                $setText(""+v);
18                }
19        ;
20
21STRING
22        :       '\1'!   // begin string (discard)
23                ( ~'\2' )*
24                '\2'!   // end string (discard)
25        ;
Note: See TracBrowser for help on using the repository browser.