lua-users home
lua-l archive

Re: Lua 5 Grammar update

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


Mike Pall wrote:
Short summary of the syntax differences between Lua 5.0 and 5.1:
- New right-assoc prefix operator SIZ: '*' expr
- New left-assoc infix operator MOD: expr '%' expr
- New VARARG expression: '...'
- Extended long strings: '[' '='* '[' longstring ']' '='* ']'
- Extended long comments: '--' '[' '='* '[' longcomment ']' '='* ']'
- The number of '=' must match up.
- Long strings and comments cannot be nested in 5.1.
Really? No nesting? I went to great lengths to support this nesting in the Scintilla lexer, too bad it disappears... Well, actually, I was worried how to manage nested counts of signs. It would have been more difficult, indeed, unless using lot of (slow) trackback, so it is actually easier this way... But it can be annoying, at least for comments, with the classical (in C language at least) problem of wanting to comment out a large section of code already using block comments.
Falling back usually to the classical #if 0 or #ifdef DEACTIVATED...
What is the reason for this "regression"? Too difficult to parse, even for the native Lua parser? Too confusing?
Mmm, did my job and searched the archive...
Gavin Wraith expressed the same concern in a 2005年05月19日 message...
OK, if I understand correctly Roberto's answer, you cannot nest comments of same level (same number of = signs) but you can nest comments of different levels, ie. it is legal to write:
--[==[ Comment out large section of code
Foo()
print [[C:\Program Files42円.txt]]
Bar()
]==]
while you cannot write: a = [=[ Groo [=[ Stupid ]=] Wanderer ]=]
Am I right? This make sense!
Is [=[ Blah [==[ Hoops ]==] Goo ]=] legal? I suppose so, I guess levels are just for differentiation, not for deepness.
OK, so I must find a trick to support 5.1 in Scintilla lexer for Lua...
--
Philippe Lhoste
-- (near) Paris -- France
-- http://Phi.Lho.free.fr
-- -- -- -- -- -- -- -- -- -- -- -- -- --

AltStyle によって変換されたページ (->オリジナル) /