[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Lexer and syntax highlighter powered by LPeg
- From: mitchell <mforal.news@...>
- Date: Sat, 07 Apr 2007 10:10:51 -0400
You mean my code isn’t documented clearly enough? I’ll add some more
comments, though my problem is always deciding which parts need them,
since LPeg already has clearly defined operators and spelling everything
out in human language quickly gets redundant.
I am having trouble understanding the following. (I don't think it's
documented very clearly)
Oh no, sorry; I meant the LPeg documentation. I found a reference to
what you were saying in the LPeg.P function, but your code had a single
number, so I wasn't sure if it was the same thing.
> P "'" * ((1 - S "'\r\n\f\\") + (P '\\' * 1)) ^ 0 * "'" What is the P
'\\' * 1 for? Does it match a \ and then any single character?
Correct. A plain number matches/consumes it’s own number of characters.
I should probably have matched the full escape but I didn’t because I
don’t think there are any error cases to handle. This would be the
local escape = S ""\r\n\f\\"
local sq_string = P "'" * ((1-escape) + (P'\\' * escape))^0 * "'"
That's what I was thinking when I was looking over it, thanks for
also just noticed that the above could be made faster (I think):
local sq_string = P "'" * ((1-escape)^0 + (P'\\' * escape))^0 * "'"
Have a nice day,
- Peter Odding