[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua 5 Grammar update
- From: Mike Pall <mikelu-0507@...>
- Date: Fri, 29 Jul 2005 13:19:12 +0200
Hi,
Mike Pall wrote:
> 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.
Uh wait ... I guess this sentence is still ambiguous. It was
meant to show the differences between Lua 5.0 and 5.1.
But 5.1 just doesn't deal with nesting at all (while 5.0 did).
So here's an unambiguous algorithm instead:
If you just parsed '[' '='* '[', then search for ']' '='* ']'
(with the exact same number of '=') and collect everything in
between as a long string (or long comment if preceded by '--').
If the first character inside the long string is a '\n',
then strip it (do this only once).
Bye,
Mike