Did you mean to disallow an expression as the first statement in your "block"?
Waldemar
On 06/01/11 18:49, Mike Samuel wrote:
2011/6/1 Waldemar Horwat<[email protected]>:
Yes, if you make it mandatory to parenthesize statements then this would
work, except for the important case of blocks.
I agree that blocks are sticky but important.
The approach below is a way to handle blocks. It's not particularly
pretty, but I don't think it's syntactically ambiguous.
Add to existing primary expression the following production
"(" (lookahead in [break, continue, do, for, if, return, switch,
throw, try, while])
ExpressionBlock ")"
Define the following Expression productions
ExpressionBlock ::== EmbeddedStatement ( ";" EmbeddedStatement )*
EmbeddedStatement ::== ExpressionStatement
| BreakStatement
| ContinueStatement
| IfStatement
| IteratorStatement
| ReturnStatement
| SwitchStatement
| ThrowStatement
| TryStatement
A block can be a series of semicolon *separated* (not terminated)
statements inside parentheses.
This introduces no additional hanging else risk.
Note that labelled statement is not in that list so an EcmaScript
program can still be treated by editor paren matchers and jump
forward/back macros as a tree of nested parenthetical and curly
bracket regions. Within a group at the same level of nesting,
semicolons define broad divisions, commas narrower divisions, and
colons narrower still.
Waldemar
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss