I've been experimenting with various possible syntaxes for <*...*> in the ANTLR 
grammar, here are my current thoughts (I'd like some feedback).

I had proposed in 2012-09-02 
(http://www.mail-archive.com/readable-discuss@lists.sourceforge.net/msg00806.html)
 that they have this semantic: "<* ... *>" are like ( ... ) in that they 
surround a list, but they do NOT turn off indentation processing. A "<*" resets 
the "indent" level to a 0-length string, skips all horizontal whitespace, and 
then restarts reading an expression with indentation processing still live. A 
blank line inside <* ... *> ends an expression WITHIN the <* ... *>, but stays 
within <* ... *>; only eof or active *> can close the <*. Once all that mapping 
is done, the range of <* ... *> is replaced with the mapped result.

But these semantics for <* ... *> that I had originally proposed turn out to be 
subtly tricky to do.  Indented expressions (i_expr) "expect" to be terminated 
by end-of-line.  Terminating them also with "*>" the "obvious" way means I have 
to insert empty alternatives everywhere, which creates a bunch of ambiguities.  
I can allow empty matches & force "greedy" matching everywhere, but that is 
complex and also turns off lots of checks I'd rather not disable.  Especially 
because it also makes the grammar much more complex, increasing the likelihood 
of errors.  In addition, doing this might make it harder for some people to 
implement.  That level of global complication seems unwarranted; we want 
simple, not complicated.

But I think that's completely unnecessary.  Basically, <* ... *> is supposed to 
create a list but yet keep indentation processing enabled, and I think there 
are two easily-distinguished use cases:
1. Multi-line case, e.g., so that blank line doesn't end all expressions.
    This basically keeps things from marching to the right-hand-side forever, 
and is useful
    for things like library definitions, where you want blank line to not end 
the *entire* expression.
    It's easy to require that, in this case, "<*" must be followed by an 
end-of-line.
2. "All on one line" - the <*...*> is on one line, e.g., one-variable let:
  let <* x cos(0) *>
  In this case, we could require that "<*" and spaces be followed by a 
(one-line) "head" production;
  by only using "head" we eliminate the ambiguities that hit the "obvious" 
approach.  If we do this,
  we might need to move "$" processing into the "head" production so "$" can be 
used inside the <* ... *>,
  and forbid the use of "$ at the end of a line", but I don't see a real need 
for that particular rule.

 --- 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
Readable-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/readable-discuss

Reply via email to