Re: How to switch lexers midflight?
Gracjan Polak <[email protected]> Wed, 17 Feb 2016 23:43:18 +0100
| Newsgroups | gmane.emacs.semantic |
|---|---|
| Message-ID | <CAChsM3QJ=B+RLS-cYqaV0iNPNpWN0oLLOOWkxtms_bJkbbBS1g@mail.gmail.com> |
I've done some more research.
Lexer has the 'depth' parameter that can be used to differentiate between
block parse and token parse.
But then there is the incremental parse, and lexer called from there gets
'depth' nil so my lexer thinks we are parsing block level structure again.
I tried to use usual lexer-hack, like this:
lexer-block-mode : (set-semantic-lexer-set-mode 'block-mode)
;
lexer-token-mode : (set-semantic-lexer-set-mode 'token-mode)
;
topblock : lexer-block-mode TOPBLOCK
(progn
(message "Reparsing topblock '%s'" $2)
(EXPANDFULL $2 topdecl))
;
topdecl : lexer-token-mode decl
(identity $2)
;
But that did not work, lexer is called first to lex whole region instead of
being called by wisent to fetch tokens one by one.
2016-02-17 19:16 GMT+01:00 Gracjan Polak <[email protected]>:
> Hi all,
>
> I'm trying to parse Haskell, it has nice block structure where layout in
> active. For example here are three top level blocks:
>
> x = 5
>
> fun a b =
> a + b
>
> data X = A | B | C
>
> I have a lexer that can split source into blocks correctly by looking at
> indentation. Then I have a rule:
>
> %start topblock
> %start topdecl
> %token TOPBLOCK
>
> topblock : TOPBLOCK
> (EXPANDFULL $1 topdecl)
> ;
>
> topdecl : .... ;
>
> Now, the lexer used inside EXPANDFULL should be a proper Haskell
> tokenizer. How do I change tokenizer midflight?
>
> Thanks
>
> --
> Gracjan
>
>
>
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
_______________________________________________
cedet-semantic mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cedet-semantic