Re: Lexer

From: anton <>
Date: Wed, 15 Jun 2011 12:38:58 -0700 (PDT)

Thanks but sorry, I still don't get it.

Why is this not working

local preprocessor = token(l.PREPROCESSOR,#P('a') * P('ta'))

_rules = {
  { 'whitespace', ws },
  { 'preprocessor', preprocessor},
  { 'any_char', l.any_char },

not working on "New sata drives"

What does "The '#' operator matches without consuming anything" mean?
The reference says
"The order of the rules is important because of the nature of LPeg.
LPeg tries to apply the first rule to the current position in the text
it is matching. If there is a match, it colors that section
appropriately and moves on. If there is not a match, it tries the next
rule, and so on."
So, "New sata drives" will produce
3 times any_char for "New", whitespace, any_char for "s" and then
presumably preprocessor,
but at what position will LPeg go on?


P.S.: Sorry...

On 15 Jun., 15:16, Robert <> wrote:
> On Wed, Jun 15, 2011 at 2:58 PM, mitchell <> wrote:
> > Hi Anton,
> > On Wed, 15 Jun 2011, anton wrote:
> >> The main problem is that if I do something wrong in a module, TA
> >> (well, Lua) gives a meaningful
> >> error message. If I do something wrong in a lexer TA simply crashes.
> > Error messages will be printed to STDOUT or STDERR in Linux.
> Also, to quote from the manual:
> "Poorly written lexers have the ability to crash Scintilla, so unsaved
> data might be lost. However, these crashes have only been observed in
> early lexer development, when syntax errors or pattern errors are
> present. Once the lexer actually starts styling text (either correctly
> or incorrectly; it does not matter), no crashes have occurred."
Received on Wed 15 Jun 2011 - 15:38:58 EDT

This archive was generated by hypermail 2.2.0 : Thu 08 Mar 2012 - 12:11:00 EST