source: trunk/yao/share/antlr-2.7.7/examples/cpp/includeFile/Main.cpp @ 1

Last change on this file since 1 was 1, checked in by lnalod, 15 years ago

Initial import of YAO sources

  • Property svn:eol-style set to native
File size: 974 bytes
Line 
1#include <iostream>
2
3#include "Main.hpp"
4#include "PLexer.hpp"
5#include "PParser.hpp"
6
7ANTLR_USING_NAMESPACE(std)
8ANTLR_USING_NAMESPACE(antlr)
9
10// Define a selector that can handle nested include files.
11// These variables are public so the parser/lexer can see them.
12TokenStreamSelector selector;
13PParser* parser;
14PLexer* mainLexer;
15
16int main( int, char** )
17{
18        try {
19                // attach java lexer to the input stream,
20                mainLexer = new PLexer(cin);
21
22                // notify selector about starting lexer; name for convenience
23                selector.addInputStream(mainLexer, "main");
24                selector.select("main"); // start with main P lexer
25
26                // Create parser attached to selector
27                parser = new PParser(selector);
28
29                // Parse the input language: P
30                parser->setFilename("<stdin>");
31                parser->startRule();
32        }
33        catch( ANTLRException& e )
34        {
35                cerr << "exception: " << e.getMessage() << endl;
36                return -1;
37        }
38        catch( exception& e )
39        {
40                cerr << "exception: " << e.what() << endl;
41                return -1;
42        }
43        return 0;
44}
Note: See TracBrowser for help on using the repository browser.