Re: [code] [textadept] How to embed parent lexer in child lexer?

From: Mitchell <m.att.foicica.com>
Date: Mon, 20 Oct 2014 10:47:07 -0400 (Eastern Daylight Time)

Hi Joshua,

On Sat, 18 Oct 2014, Joshua Krmer wrote:

> Hi all,
>
> I have a lexer that embeds another lexer (for some special text in the
> code). That works fine using the following code:
>
>
> -- parent lexer code is above this line
>
> local special_text = {_NAME = 'special_text'}
>
> local special_word = token(l.IDENTIFIER, l.word)
>
> special_text._rules = {
> {'special_word', special_word},
> }
>
> l.embed_lexer(M, special_text, start, stop)
>
> return M
>
>
> Now I also need to return to the top-level lexing inside the special
> text area, i. e. I need to embed the parent lexer inside the child
> lexer. Is this possible? If so, how? Unfortunately, I could not come
> up with a working solution.

I don't think the "two-way" embedding you're describing is possible at the
moment. Perhaps your best bet is to change the `start` and `stop` rules to
include the new transitions from child to parent. It's not perfect, but it
may be good enough.

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 Mon 20 Oct 2014 - 10:47:07 EDT

This archive was generated by hypermail 2.2.0 : Tue 21 Oct 2014 - 06:51:13 EDT