1 /* This is test.g which tests multiple scanners/parsers; DLG-based scanner */
4 typedef ANTLRCommonToken ANTLRToken;
8 ANTLRTokenPtr aToken = new ANTLRToken;
9 DLGFileInput in(stdin);
11 scan.setToken(mytoken(aToken));
12 ANTLRTokenBuffer pipe(&scan);
13 Include parser(&pipe);
21 #token "[\ \t\n]+" <<skip();>>
27 /* this is automatically defined to be a member function of Include::
28 * since it is within the "class {...}" boundaries.
31 char *stripquotes(ANTLRChar *s)
33 s[strlen(s)-1] = '\0';
39 : ( cmd | include )* Eof
43 ( NUMBER <<printf("%s\n", $1->getText());>>
44 | STRING <<printf("%s\n", $1->getText());>>
52 f = fopen(stripquotes($2->getText()), "r");
53 if ( f==NULL ) {fprintf(stderr, "can't open %s\n", $2->getText()+1);}
55 ANTLRTokenPtr aToken = new ANTLRToken;
58 scan.setToken(mytoken(aToken));
59 ANTLRTokenBuffer pipe(&scan);
60 Include parser(&pipe);
69 #token STRING "\" [a-zA-Z0-9_.,\ \t]+ \""
70 #token NUMBER "[0-9]+"