lua-users home
lua-l archive

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


Mike Pall wrote:

Hi,

Klaas-Jan Stol wrote:
- Long strings and comments cannot be nested in 5.1.
So, just to make sure (before I start implementing the whole thing), you can't do:

[=[I said: [==[Hello World]==] to him]=]

No, I was imprecise. Sorry. My above sentence should be:

 Long strings and comments --> with the same number of '=' <--
 cannot be nested in 5.1.

As a corollary, this makes [[xx[[xx]]xx]] a syntax error
(was legal in 5.0). Different number of '=' nest properly.

$ lua51w6 -e 'print [=[I said: [==[Hello World]==] to him]=]'
I said: [==[Hello World]==] to him

$ lua51w6 -e 'print [=[I said: [[Hello World]] to him]=]'
I said: [[Hello World]] to him

$ lua51w6 -e 'print [==[I said: [==[Hello World]==] to him]==]'
lua51w6: (command line):1: '=' expected near 'him'

$ lua51w6 -e 'print [[I said: [[Hello World]] to him]]'
lua51w6: (command line):1: nesting of [[...]] is deprecated near '['

Bye,
    Mike


good thing I checked ;-)
It makes things a bit more complicated I think. Still doable, but as (^n )^n is not a regular language (according to automata ~ and language theory) so, the lexer cannot check on number of '(' == number of ')' ), this cannot be done by the lexer alone. The parser has to keep track of that.

Thanks for your trouble,

klaas-jan