[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: yet another pattern-matching library for Lua
- From: roberto@... (Roberto Ierusalimschy)
- Date: Mon, 8 Jan 2007 16:15:43 -0200
> 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