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