Re: [code] Lexer creation problem.

From: Michael Richter <ttmrichter.att.gmail.com>
Date: Sun, 8 Nov 2015 08:04:57 +0800

I solved it (literally) in my dreams last night. I keep forgetting that
I'm writing a lexer to display text in funny colours, not writing a parser
for a language recognizer. If I focus on the goal it's easy.

That being said, I didn't realize I could stick token definitions in the
middle of other token definitions. :-o

On 8 November 2015 at 00:49, Mitchell <m.att.foicica.com> wrote:

> Hi Michael,
>
> On Sat, 7 Nov 2015, Michael Richter wrote:
>
> Is there any way to have a pattern that highlights two different parts and
>> ignores boilerplate? Maybe some trick with grammars and captures? I'm
>> not
>> sure what the relationship between LPeg and the lexers is just yet.
>>
>> As an example of what I mean:
>>
>> In the string " :S(LABEL1)F(LABEL2)\n" I want LABEL1 and LABEL2
>> highlighted, but not ":S(", ")F(", or ")".
>>
>
> Lexers start lexing at the beginning of a line, so you should be able to
> use something like:
>
> ':S(' * token(l.KEYWORD, 'LABEL1') *
> ')F(' * token(l.KEYWORD, 'LABEL2') * ')'
>
>
> Cheers,
> Mitchell
> --
> 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.
>
>

-- 
"Perhaps people don't believe this, but throughout all of the discussions
of entering China our focus has really been what's best for the Chinese
people. It's not been about our revenue or profit or whatnot."
--Sergey Brin, demonstrating the emptiness of the "don't be evil" mantra.
-- 
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 Sat 07 Nov 2015 - 19:04:57 EST

This archive was generated by hypermail 2.2.0 : Sun 08 Nov 2015 - 06:27:39 EST