[antlr-interest] How to handle python-like indented code blocks

Eric Bell eric at ericjbell.com
Thu Nov 26 11:41:53 PST 2009


Could someone get me pointed in the right direction for how to parse
grammars that use indenting to identify code blocks ... like in Python?
 
I searched around and looked through the source code for boo, which uses a
python-like grammar, but I am a newbie to this and it's too much code for me
to figure out.

I am trying to parse a file that defines nodes in a tree. Indenting is used
to show that nodes are children of a parent, like this:

              s4\0 [n c] [r 0\22\33]
                     s4s4\# [n t] [p s4]
                     s4s5\.1 [n t] [p s5]

"s4", "s4s4", "s4s5" are node-names, with "s4s4" and "s4s5" being children
of node "s4". The indenting uses a tab character, with one tab per indent
level.

Thanks, 

--eric



More information about the antlr-interest mailing list