From 69016729b53b50ed728797493f22613f433e4ee0 Mon Sep 17 00:00:00 2001 From: Terence Parr <> Date: Mon, 11 Sep 1995 16:54:46 -0500 Subject: [PATCH] auto commit for import --- testcpp/2/test.g | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100755 testcpp/2/test.g diff --git a/testcpp/2/test.g b/testcpp/2/test.g new file mode 100755 index 0000000..6a86c29 --- /dev/null +++ b/testcpp/2/test.g @@ -0,0 +1,45 @@ +/* Ariel Tamches (tamches@cs.wisc.edu): + * This tests linking in a simple non-DLG scanner + */ + +/* We assume that #tokdefs is not employed for this example; i.e., + * ANTLR assigns token numbers. + * + * ANTLR option -gx must be used to turn off generation of DLG crud (when you + * want to define your own token stream). + */ + +/* user must define ANTLRToken outside of #header */ +<< +typedef ANTLRCommonToken ANTLRToken; /* use a predefined Token class */ +>> + +/* At this point, ANTLRToken and ANTLRTokenStream are defined, user must now + * derive a class from ANTLRTokenStream (which embodies the user's scanner) + */ +<<#include "MyLexer.h">> + +<< +int main() +{ + /* create one of my scanners */ + MyLexer scan; + ANTLRTokenBuffer pipe(&scan); + /* create a parser of type Expr hooked to my scanner */ + Expr parser(&pipe); + parser.init(); + parser.setEofToken(Eof); + + parser.e(); /* start parsing at rule 'e' of that parser */ + return 0; +} +>> + +class Expr { /* Define a grammar class */ + +e : IDENTIFIER NUMBER + <getText(), $2->getText());>> + Eof + ; + +} -- 2.40.0