[antlr-interest] Peel-off Tree Parser patch

Akhilesh Mritunjai virtualaspirin at yahoo.com
Thu Jun 23 13:54:43 PDT 2005


Hi folks

Completed a small work last night on antlr.

I have a fairly involved grammar for a poorly designed
language. My parser builds AST from it and then I have
an army of tree-parsers to do transformation on it. (I
said language is poorly designed... multiple passes
are non-avoidable). Each tree parser does its job on
small subsections of tree, so writing a complete
grammar is useless and additional effort on small
manpower we have.

Some tree-parsers are lucky enought to be able to work
"in-place". The not so fortunate ones have to build a
new tree from scratch because of huge number of
changes to input tree, though localized.

So, I want my whole tree copy back after applying
transformations and no way I'm gonna write complete
grammar. So I've added a boolean option "dupTree" that
when used along with "buildAST = true", will 'dupTree'
the non-terminals in grammar, so any children beneath
it will also be present in output tree.

I've tested the fix, it works well and doesn't break
anything else. Please let me know if its interesting
enough... I'm attaching diffs against antlr-2.7.6b1.

Thanks
- Akhilesh

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: antlr.diff
Type: application/octet-stream
Size: 5170 bytes
Desc: 645793284-antlr.diff
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20050623/04ce77dc/antlr.obj


More information about the antlr-interest mailing list