[antlr-interest] Reload an AST from serialized form.
Tommy Nordgren
tommy.nordgren at comhem.se
Mon Aug 3 11:29:51 PDT 2009
I have written the following small antlr grammar, to unserialize an
AST from the output generated by the toStringTree() method.
I'm sending it to the list, since I think it would be useful for many
antlr users.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SymTabLoader.g
Type: application/octet-stream
Size: 436 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20090803/252807ed/attachment.obj
-------------- next part --------------
parser grammar SymTabLoader;
/* Unserializes an AST serialized with toStringTree - uses the input
lexer symbols used to create the
ast initially. Note: EVEN abstract tokens need to have a lexical
representation for this to work.*/
options {
tokenVocab = InputSyntax;
output = AST;
}
program : module ;
module : '(' firstSymb subTree* ')' -> ^(firstSymb subTree*) ;
firstSymb :
~( '(' | ')' )
;
subTree : firstSymb
| module
;
---------------------------------
How many National Democrats does it take to change a light bulb?
108: 8 who smashes the rest of the light bulbs, and 100 to blame a
zionist world conspiracy for the darkness
--------------------------
Tommy Nordgren
tommy.nordgren at comhem.se
More information about the antlr-interest
mailing list