- Visual C++源码
- Visual Basic源码
- C++ Builder源码
- Java源码
- Delphi源码
- C/C++源码
- PHP源码
- Perl源码
- Python源码
- Asm源码
- Pascal源码
- Borland C++源码
- Others源码
- SQL源码
- VBScript源码
- JavaScript源码
- ASP/ASPX源码
- C#源码
- Flash/ActionScript源码
- matlab源码
- PowerBuilder源码
- LabView源码
- Flex源码
- MathCAD源码
- VBA源码
- IDL源码
- Lisp/Scheme源码
- VHDL源码
- Objective-C源码
- Fortran源码
- tcl/tk源码
- QT源码
test.g
资源名称:pccts133.zip [点击查看]
上传用户:itx_2006
上传日期:2007-01-06
资源大小:493k
文件大小:1k
源码类别:
编译器/解释器
开发平台:
Others
- /* Ariel Tamches (tamches@cs.wisc.edu):
- * This tests linking in a simple non-DLG scanner with user-defined token
- * types.
- */
- /* All TokenType's must have some end-of-file token; You must define
- * it with setEofToken() to your end of input token.
- *
- * We assume that #tokdefs is employed for this example; i.e., ANTLR does
- * NOT assign token numbers.
- *
- * ANTLR option -gx must be used to turn off generation of DLG crud (when you
- * want to define your own token stream).
- */
- #tokdefs "mytokens.h"
- /* user should define ANTLRToken outside of #header since AToken.h would
- * not have been included yet. You can force inclusion of AToken.h if
- * you must use #header, however.
- */
- <<
- 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 {
- e : IDENTIFIER NUMBER
- <<fprintf(stderr, "text is %s,%sn", $1->getText(), $2->getText());>>
- Eof
- ;
- }