1
/* This is test.g which tests multiple scanners/parsers; DLG-based scanner;
2
* also, we test multiple lexical classes.
6
typedef ANTLRCommonToken ANTLRToken;
11
ParserBlackBox<Lexer, Include, ANTLRToken> p(stdin);
17
#token "[\ \t\n]+" <<skip();>>
24
/* this is automatically defined to be a member function of Include::
25
* since it is within the "class {...}" boundaries.
28
char *stripquotes(ANTLRChar *s)
30
s[strlen(s)-1] = '\0';
36
: ( cmd | include )* "@"
40
( NUMBER <<printf("%s\n", $1->getText());>>
41
| STRING <<printf("%s\n", $1->getText());>>
49
f = fopen(stripquotes($2->getText()), "r");
50
if ( f==NULL ) {fprintf(stderr, "can't open %s\n", $2->getText()+1);}
52
ANTLRTokenPtr aToken = new ANTLRToken;
55
scan.setToken(mytoken(aToken));
56
scan.mode(Lexer::DATA);
57
ANTLRTokenBuffer pipe(&scan);
58
Include parser(&pipe);
67
#token "[\ \t\n]+" <<skip();>>
69
data: "0x[0-9]+" ":" "0x[0-9]+"
70
<<printf("data %s\n", $1->getText());>>
77
#token STRING "\" [a-zA-Z0-9_.,\ \t]+ \""
78
#token NUMBER "[0-9]+"