I am new to antlr and I need some help with using it in C/C++.

I already created a grammar that I want to use and tested it with
antlr-works, and then I generated the C files from it.

Now I need to write a program that uses the parser, and unfortunately it
is far from obvious of how do I even start. I tried to find help in the
documentation, and I tried to guess by looking at the generated files.

I expect that it should be pretty much straightforward, so I need a
simple example.

I understand that basically I need to do the following:

1. Prepare the text to be parsed. In my case it will be a text string in
memory (not a disk file). Should it be just a "const char *"? 

2. Invoke a call to the parser and pass my string to it. How does it
look like? How do I get back the status code and the parsing errors?

3. Get the tree root. How?

4. Walk through the tree. Need an example how this is done. On each node
I will need to figure out what kind of node that is (looks like the
integer constants are defined in generated code for each node type). If
a node represents some value, need to get it.

If I can do the above procedure, I can generate whatever I need based on
the tree.

Thanks in advance for your help.

- Leonid

--------------------------------------------------------------------------
This message w/attachments (message) may be privileged, confidential or 
proprietary, and if you are not an intended recipient, please notify the 
sender, do not use or share it and delete it. Unless specifically indicated, 
this message is not an offer to sell or a solicitation of any investment 
products or other financial product or service, an official confirmation of any 
transaction, or an official statement of Merrill Lynch. Subject to applicable 
law, Merrill Lynch may monitor, review and retain e-communications (EC) 
traveling through its networks/systems. The laws of the country of each 
sender/recipient may impact the handling of EC, and EC may be archived, 
supervised and produced in countries other than the country in which you are 
located. This message cannot be guaranteed to be secure or error-free. This 
message is subject to terms available at the following link: 
http://www.ml.com/e-communications_terms/. By messaging with Merrill Lynch you 
consent to the foregoing.
--------------------------------------------------------------------------
 

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---

List: http://www.antlr.org:8080/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org:8080/mailman/options/antlr-interest/your-email-address

Reply via email to