lua-users home
lua-l archive

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


Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br> writes:
>> Couldn't the lexer recognize any instance of two string-enclosing  
>> sequences around a concatenation operator? (This would also result in the  
>> ability to avoid constant folding by putting parentheses around a string.)
>
> This was discussed last time as well. This solution requires unbounded
> lookahead (and is a parser task, not a lexical task). Consider
> 	a= ("hello".."world".."from".."Lua")
> versus
> 	a= ("hello".."world".."from".._VERSION)

Wait, why is that different than
	a= ("helloworldfrom".."Lua")
versus
	a= ("helloworldfrom".._VERSION)
?

Couldn't Lua's lexer, while reading a "-delimited string, just
squash an embedded "<ws>..<ws>" sequence without the parser ever
even knowing about it (where <ws> means [ \t\n])...?

You can put limits on <ws> and just say "this lexer optimization is
only done when the source code is within the stated limits; anything
else is just left as separate strings and an explicit concatenation
operator".

-Miles

-- 
Quack, n. A murderer without a license.