BTW, here's a simple example of the i_expr production. Imagine that you have:
f a b
! stuff1
! stuff2
Here I'll walk through how it's parsed, focusing on i_expr.
When i_expr starts, it will in turn call "head" to read in the line; "head"
will return "(f a b)". It ends with end-of-line, so we drop to this part of
the production:
> | comment_eol // Normal case, handle child lines if any:
> (indent body2=body {$v = append($head.v, $body2.v);}
> | empty {$v = monify($head.v);} /* No child lines */ ))
We have an "indent" after EOL, so we get to the "body2=body" production. Body
will call i_expr to process. "stuff1". This i_expr invocation will read a head
of (stuff1), followed by EOL with no child lines; this i_expr will monify
"(stuff1)" producing "stuff1" as its return value. The same thing happens to
stuff2. In the end, body will return the list of all the body expressions, in
this case (stuff1 stuff2).
Once body returns to the production of i_expr that started reading "f a b...",
the i_expr production will append the body after the head. In this case, this
means it will run (append '(f a b) '(stuff1 stuff2)), producing (f a b stuff1
stuff2) as expected.
ANTLR has some really cool parser-specific debugging capabilities, you can
plunk in a sample and graphically see the parse tree if you want to walk
through stuff like this.
--- David A. Wheeler
------------------------------------------------------------------------------
Master HTML5, CSS3, ASP.NET, MVC, AJAX, Knockout.js, Web API and
much more. Get web development skills now with LearnDevNow -
350+ hours of step-by-step video tutorials by Microsoft MVPs and experts.
SALE $99.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122812
_______________________________________________
Readable-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/readable-discuss