Re: [code] Lexer creation problem.

From: Michael Richter <ttmrichter.att.gmail.com>
Date: Sun, 8 Nov 2015 10:19:19 +0800

For what it's worth, here's a lexer you can dump into the distribution if
you like Mitchell. It makes reading SNOBOL4 code almost a possibility. :)

http://vpaste.net/wDMHe

(Also attached, but since some mailers strip attachments, the link is
provided as well.)

I've got lexers for a couple of other languages in the works here, updating
from v7.2 to current before I can release them. (They all started breaking
in 7.3, so I never got around to updating until now because of lack of
time.) As I make them, if you're interested, I'll hand them across to
you. They're all WTFPL so there's no issue in distributing them.

On 8 November 2015 at 08:04, Michael Richter <ttmrichter.att.gmail.com> wrote:

> 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.
>

-- 
"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 - 21:19:19 EST

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