lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Fri, Jul 6, 2018, at 05:18, Gé Weijers wrote:

The language BCPL used a fairly simple strategy to detect statement ends:

Let E be the set of symbols that can end a statement, and S be the set of symbols that can start a statement. If the lexical analyzer sees a symbol in E followed by a newline, follow by a symbol in S it inserts a semicolon between them. 

For Lua E would include identifiers, literals and all the closing brackets, and S would include identifiers, literals and opening brackets.

It would be interesting to see whether this could be made to work well for Lua. In terms of LR parsing, the parser would resolve these shift-reduce ambiguities with a shift, except when a newline occurs.


This would be a pretty big change to the language, since as of today newlines have no special meaning in Lua.

For reference, the manual documents the ambiguity and how it is resolved ( https://www.lua.org/manual/5.3/manual.html#3.3.1 ).