1 /* This is test.g which tests a simple DLG-based scanner
2 * with user-defined tokens
5 /* Here, we use #tokdefs to define token types, but still let DLG do the
6 * lexing. ANTLR will not create a tokens.h file.
11 #include "DLGLexer.h" /* include definition of DLGLexer.
12 * This cannot be generated automatically because
13 * ANTLR has no idea what you will call this file
14 * with the DLG command-line options.
17 typedef ANTLRCommonToken ANTLRToken;
21 ANTLRTokenPtr aToken = new ANTLRToken;
22 DLGFileInput in(stdin);
24 ANTLRTokenBuffer pipe(&scan);
25 scan.setToken(mytoken(aToken));
34 #token "[\ \t\n]+" <<skip();>>
36 class Expr { /* Define a grammar class */
38 e : IDENTIFIER NUMBER "@"
39 <<fprintf(stderr, "text is %s,%s\n", $1->getText(), $2->getText());>>
44 #token IDENTIFIER "[a-z]+"
45 #token NUMBER "[0-9]+"