[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
*Almost* free-form syntax
Hi,
I'm trying to write a parser for the Lua language (http://www.lua.org)
The problem is that the grammar is *almost* free-form, with one little
exception. The manual says:
"As an exception to the free-format syntax of Lua, you cannot put a line
break before the `(´ in a function call. That restriction avoids some
ambiguities in the language."
Here is a part of the grammar that is giving me headaches:
functioncall = prefix_expr args;
args = '(' expr_list? ')';
prefix_expr = '(' expr ')';
This is the ambiguity:
shift/reduce conflict in state [stack: PFunctionCall *] on TTokLparen in {
[ P$Stat = PFunctionCall * ] followed by TTokLparen (reduce),
[ PArgs = * TTokLparen PExprList TTokRparen ] (shift),
[ PArgs = * TTokLparen TTokRparen ] (shift)
}
The linebreaks are thrown away by the lexer. How can I solve this??
Thanks,
Danilo