Problem with LPEG- grammar
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Problem with LPEG- grammar
- From: Wolfgang Pupp <wolfgang_pupp@...>
- Date: 2008年10月21日 17:13:36 +0000 (GMT)
Trying to realise a parser for boolean expressions (its, admittedly, my first "project" with LPEG),
i stumbled across a problem i couldn't solve:
require"lpeg"
unaryOp = "!" --unary Operator
binaryOp = "&&" --binary Operator
expression = lpeg.P{
"Exp"; --Rule 1
Exp = lpeg.V"uExp" + lpeg.V"bExp",
uExp = lpeg.V"Exp" * unaryOp,
bExp = lpeg.V"Exp" * binaryOp * lpeg.V"Exp",
}
This (simplified beyond sensefulness) piece of code fails: "rule 'bExp' is left recursive" says the
interpreter (but uExp works fine).
But wheres the problem? If it wasnt recursive, i wouldn't use a grammar table...
Am I doing something wrong? Or is this the reason for the "0.9" version number of the LPEG- lib?
By the way, the LPEG- library is just great- I really enjoyed to use it (std. regular expressions with Lua? never again!) till this problem arised...
Wolfgang
PS: Thanks in advance for your help (and for Lua and LPEG)!