[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: lpeg/re documentation bug
- From: "varol kaptan" <varol.kaptan@...>
- Date: Tue, 22 Apr 2008 21:47:31 +0100
Today I noticed that the CVS decoder example at
http://www.inf.puc-rio.br/~roberto/lpeg/re.html is not correct.
After looking at the example I was misled to think that '\n' will be
un-escaped into a newline, however, examination of the source code
reveals that this is not true. The current code snippet will fail to
parse something like '123,12n3'.
A correct one looks like this:
record = re.compile[[
record <- ( <field> (',' <field>)* ) -> {} ( [%nl] / !.)
field <- <escaped> / <nonescaped>
nonescaped <- { [^,"%nl]* }
escaped <- '"' {~ ([^"] / '""' -> '"')* ~} '"'
]]
Thanks
Varol Kaptan