Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
test.g
Package: pccts133.zip [view]
Upload User: itx_2006
Upload Date: 2007-01-06
Package Size: 493k
Code Size: 1k
Category:
Compiler program
Development Platform:
Others
- /* This is test.g which tests multiple scanners/parsers; DLG-based scanner */
- <<
- #include "Lexer.h"
- typedef ANTLRCommonToken ANTLRToken;
- int main()
- {
- ANTLRTokenPtr aToken = new ANTLRToken;
- DLGFileInput in(stdin);
- Lexer scan(&in);
- scan.setToken(mytoken(aToken));
- ANTLRTokenBuffer pipe(&scan);
- Include parser(&pipe);
- parser.init();
- parser.input();
- return 0;
- }
- >>
- #token "[ tn]+" <<skip();>>
- #token Eof "@"
- class Include {
- <<
- /* this is automatically defined to be a member function of Include::
- * since it is within the "class {...}" boundaries.
- */
- private:
- char *stripquotes(ANTLRChar *s)
- {
- s[strlen(s)-1] = '';
- return &s[1];
- }
- >>
- input
- : ( cmd | include )* Eof
- ;
- cmd : "print"
- ( NUMBER <<printf("%sn", $1->getText());>>
- | STRING <<printf("%sn", $1->getText());>>
- )
- ;
- include
- : "#include" STRING
- <<{
- FILE *f;
- f = fopen(stripquotes($2->getText()), "r");
- if ( f==NULL ) {fprintf(stderr, "can't open %sn", $2->getText()+1);}
- else {
- ANTLRTokenPtr aToken = new ANTLRToken;
- DLGFileInput in(f);
- Lexer scan(&in);
- scan.setToken(mytoken(aToken));
- ANTLRTokenBuffer pipe(&scan);
- Include parser(&pipe);
- parser.init();
- parser.input();
- }
- }>>
- ;
- }
- #token STRING "" [a-zA-Z0-9_., t]+ ""
- #token NUMBER "[0-9]+"