lua-users home
lua-l archive

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


> One other change - detecting infinite loops - might have a small
> problem.  Wouldn't it normally be the case that if match(e,p) succeeds
> that match(e,p^0) should as well?

No. The semantics for "p^0" is:

  match p; if success, match p^0; else fail.

So, if p matches the null string, p^0 is a loop. The semantics is
very algorithmic. These loops are part of the semantics...

The POPL paper about PEGs defines the notion of a "well-formed grammar"
(a well-formed grammar is garanteed to have no loops).  If p -> "" (that
is, p matches the empty string), p^0 is not well formed.

-- Roberto