lua-users home
lua-l archive

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

Hi All,

I'm looking for an LPeg-based parser that can handle partial content
or invalid syntax and still continue processing. I've looked at the
code of several LPeg-based parsers (many of them referenced in this
thread:, but
none of them seems to be able to continue processing after
encountering invalid syntax. For example,

n = 5
while n > 1 do
   n := n-1 --<-- syntax error

I'd like to be able to build AST and mark the "unknown" node as
"unknown" and continue processing. I'd also like to be able to handle
incomplete fragments:

n = 5
while n > 1 do

This would generate a node for "while" and mark it as "incomplete" as
there is no corresponding "end" to close that statement.

I've been using David Manura's loose parser
(, which does something
like this, but I'm interested in LPeg-based solution.

Does anyone have an example of how this can be done with LPeg? Thank you.