Re: [code] Need some LPEG advice.

From: Mitchell <m.att.foicica.com>
Date: Sun, 14 Feb 2016 18:44:40 -0500 (EST)

Hi Markus,

On Sun, 14 Feb 2016, Markus F.X.J. Oberhumer wrote:

> Hi,
>
> I initially discovered lua & textadept by stumbling over lpeg, and
> playing with the lexers actually is the real fun in textadept.
>
> I've now tried to improve to C/C++ lexer to detect function calls (easy)
> and function definitions (hard) - I'm stuck with the equivalent of
>
> entity.name.function.c
> entity.name.function.c++
>
> Any hints?

That's going to be difficult because Scintilla (Textadept's editing
component) lexes (or syntax-highlights) starting at the beginning of
lines, usually without backtracking. Thus C/C++ function definitions like

     int
     main(int argc, char **argv)
     {
       ...
     }

will be tough because whenever you start editing on the "main" line,
Scintilla will ask for lexing starting on that line (thus ignoring the
previous "int" line, which it already considers as correctly lexed). At
the moment I do not know how to always correctly style "main" as a
function. It will often work on the first pass, but may fail on subsequent
edits, like the one mentioned above.

> Somewhat related, would it be possible to automatically convert these
> .plist/.yaml syntax files to LPEG?

LPeg has an "re" module[1] that attempts to map regexes to LPeg patterns.
It may be of help.

Cheers,
Mitchell

[1]: http://www.inf.puc-rio.br/~roberto/lpeg/re.html

-- 
You are subscribed to code.att.foicica.com.
To change subscription settings, send an e-mail to code+help.att.foicica.com.
To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
Received on Sun 14 Feb 2016 - 18:44:40 EST

This archive was generated by hypermail 2.2.0 : Mon 15 Feb 2016 - 06:48:23 EST