[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: patch: C-style string lexing
- From: David Manura <dm.lua@...>
- Date: Fri, 1 Feb 2008 18:50:34 +0000 (UTC)
Luiz Henrique de Figueiredo writes:
> > can you do the folding of the string concatenation in the lexer?
> I don't think so. That's exactly the original problem: you cannot translate
> f"A".."B" into f"AB":
Eric, your patch could likely be salvaged if it were to concatenate adjacent
strings only when they are preceded by an open parenthesis:
a("b" "c") --> a "bc"
a "b" "c" --> (a "b") "c"
I think that would be do-able entirely in the lexer, and the new syntax doesn't
interfere with exiting syntax.
More generally, you might want to substitute "open parenthesis" with "not
prefixexp", but detecting prefixexp typically would require help from the parser.
Example usage:
io.write("This is a big chunk of text "
"that for whatever reason (typically "
"readability) is broken into multiple "
"lines in the source code.\n")
Mildred's alternate suggestion for Lisaac-like approach is also quite simple.
These things can all be done directly in the lexer or via an external
preprocessor (e.g. see http://lua-users.org/wiki/LuaGrammar ).