Re: [code] Lexer creation problem.

From: Mitchell <m.att.foicica.com>
Date: Sat, 7 Nov 2015 09:19:22 -0500 (EST)

Hi Michael,

On Sat, 7 Nov 2015, Michael Richter wrote:

> lexer.word_match() acts in a way that's a bit puzzling to me and I'm trying
> to work out how to get around it. The issue is this: if I have a token
> defined as, say lexer.word_match({"NE"}), this works as expected. "NE" is
> properly highlighted in my file. FOO BAR NE BAZ has FOO, BAR, and BAZ not
> highlighted and NE highlighted. Perfect. Until I feed it FOO BAR FINE
> BAZ. Then NE is again highlighted. Which is really not how one generally
> wants for keyword highlighting.
>
> So ... how do I nicely have keywords that are highlighted only when they're
> standing alone?

You need to have another rule that matches whole words, typically an
"identifier" rule. Make sure your keyword rule comes first though. That
way when a keyword doesn't match, your "identifer" rule will pick it up
(e.g. "FINE"), and there won't be a possibility for "NE" to be matched
alone.

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.
Received on Sat 07 Nov 2015 - 09:19:22 EST

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