1 /* Ariel Tamches (tamches@cs.wisc.edu):
2 * This tests linking in a simple non-DLG scanner
5 /* We assume that #tokdefs is not employed for this example; i.e.,
6 * ANTLR assigns token numbers.
8 * ANTLR option -gx must be used to turn off generation of DLG crud (when you
9 * want to define your own token stream).
12 /* user must define ANTLRToken outside of #header */
14 typedef ANTLRCommonToken ANTLRToken; /* use a predefined Token class */
17 /* At this point, ANTLRToken and ANTLRTokenStream are defined, user must now
18 * derive a class from ANTLRTokenStream (which embodies the user's scanner)
20 <<#include "MyLexer.h">>
25 /* create one of my scanners */
27 ANTLRTokenBuffer pipe(&scan);
28 /* create a parser of type Expr hooked to my scanner */
31 parser.setEofToken(Eof);
33 parser.e(); /* start parsing at rule 'e' of that parser */
38 class Expr { /* Define a grammar class */
41 <<fprintf(stderr, "text is %s,%s\n", $1->getText(), $2->getText());>>