Re: {Spam?} Re: state in parsers
Kristof Bastiaensen <[email protected]> Wed, 16 Dec 2015 17:14:17 +0100
| Newsgroups | gmane.emacs.semantic |
|---|---|
| Message-ID | <[email protected]> |
So wisent calls wisent-lex. Could I implement semantic-lex to
generate all tokens except implicit layout, then rewrite wisent-lex to take
these tokens, handle context (based on indentations), and insert
implicit-layout
tokens when necessary. Then the parser could pop the context where
necessary. This should work unless wisent-lex caches the tokens.
Kristof
On 15-12-15 20:20, David Engster wrote:
> Kristof Bastiaensen writes:
>> Can the lexer be controlled from the parser, or are they
>> totally separated? Can I modify lexer state from the parser?
>> Is that such a hard question?
> It is.
>
> The lexer and the parser are separated. But since this is Emacs Lisp,
> nothing really is 'totally' separate. Since you can call pretty much any
> Emacs Lisp code in your actions, you are free to set some variable there
> which affects how your lexers work.
>
> The LL parser (Bovine) does something similar with the EXPAND/EXPANDFULL
> actions, which incrementing a 'depth' variable and call the parser
> recursively. This variable defines the depth with which the lexers
> should look into '{}' and '()' blocks (otherwise they simply return a
> 'semantic-list' token).
>
> AFAIK, the Wisent parser does not support this out of the box, but you
> should be able to cook up something similar, but maybe you have to dig
> into the Wisent code a bit to get this right. Sorry I cannot give you a
> better answer.
>
> -David
------------------------------------------------------------------------------