1 /* Ariel Tamches (tamches@cs.wisc.edu):
2 * This tests linking in a simple non-DLG scanner with user-defined token
6 /* All TokenType's must have some end-of-file token; You must define
7 * it with setEofToken() to your end of input token.
9 * We assume that #tokdefs is employed for this example; i.e., ANTLR does
10 * NOT assign token numbers.
12 * ANTLR option -gx must be used to turn off generation of DLG crud (when you
13 * want to define your own token stream).
18 /* user should define ANTLRToken outside of #header since AToken.h would
19 * not have been included yet. You can force inclusion of AToken.h if
20 * you must use #header, however.
23 typedef ANTLRCommonToken ANTLRToken; /* use a predefined Token class */
26 /* At this point, ANTLRToken and ANTLRTokenStream are defined, user must now
27 * derive a class from ANTLRTokenStream (which embodies the user's scanner)
29 <<#include "MyLexer.h">>
34 /* create one of my scanners */
36 ANTLRTokenBuffer pipe(&scan);
37 /* create a parser of type Expr hooked to my scanner */
40 parser.setEofToken(Eof);
42 parser.e(); /* start parsing at rule 'e' of that parser */
50 <<fprintf(stderr, "text is %s,%s\n", $1->getText(), $2->getText());>>