[antlr-interest] how do you make Antlr work with a recursively changing input stream
Alex McMains
alex_mcmains at yahoo.com
Tue Jun 29 15:18:55 PDT 2010
Hi all,
I'm new to Antlr. I've bought and read portions of the Antlr book, and I've read dozens of postings and tutorials, but I still can't see how to do deal with a recursively changing input stream in Antlr. Do I somehow use TokenRewriteStream, or am I missing something?
Here's the situation:
I start with an input stream. As I move through the input I will either encounter something that can be parsed directly, or I will encounter something that tells me to go to a table and substitute an entire row of the table at the node where I currently am. This can continue to happen recursively since each field from the substituted row can again call for a substitution.
Here's an example:
Person table:
_Identifier_ Name {Address}
Person1 Jon Jon's Address
Address table:
_Identifier_ HouseNumber StreetName
Jon's Address 3477 Blue Lane
The {} around Address says to name the current node "Address" and substitute the current value for whatever is at "Jon's Address" in the Address table.
Eventually this will become XML that would look like:
<Person>
<Name>Jon</Name>
<Address>
<HouseNumber>3477</HouseNumber>
<StreetName>Blue Lane</StreetName>
</Address>
</Person>
Any ideas would be appreciated.
Thanks.
-- alex
More information about the antlr-interest
mailing list