I have a better BNF model for RESTART_END. In particular, this version makes
the BNF and implementation *incredibly* easy and clean.
Basically, I think we should model the "*>" during indentation processing as
generating TWO tokens, EOL (end-of-line) followed by RESTART_END. The EOL
token forces the end of head/rest/i_expr, if it's in the middle of processing
one, taking advantage of the existing rules and structure. Doing it this way
completely avoids all grammar ambiguities, which means that the ANTLR tool
continues to be useful in checking for grammar problems.
Implementations don't actually have to generate 2 tokens; I include in the BNF
some documentation on how to implement it while generating one token if
desired. But although doing it that way only requires one more line in the
production, it is VERY hard to explain *why* that line works (indeed, it's
possible that it doesn't, thought I think it does). I want the BNF to be
easy-to-reason-about. In general, I want this whole thing to be as "obviously
correct" as I can make it. Doing it this way makes it MUCH easier to
understand and be sure it's right.
I've also tweaked the restart_tail to be this:
restart_tail returns [Object v]:
i_expr rt=restart_tail {$v = cons($i_expr.v, $rt.v);}
| comment_eol retry=restart_tail {$v = $retry.v;}
| restart_end_nt {$v = null;} ;
This handles arbitrary blank lines in a cleaner way. Now blank lines can
precede, follow, or be intermixed between the i_expr, and it's pretty obvious
why that would be okay. The "restart_end_nt" is just the RESTART_END
non-terminal.
--- David A. Wheeler
------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnmore_123012
_______________________________________________
Readable-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/readable-discuss