lua-users home
lua-l archive

lpeg/re documentation bug

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


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

AltStyle によって変換されたページ (->オリジナル) /