dcsimg
Using multiple lexers
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Torsten_Fichtner
Posted On:   Thursday, September 18, 2003 10:42 AM

Hi, I want to create a parser, which change after special keys to a lexer. This second lexer is used to skip all input tokens until an end key will be recognized. I defined the following parser rules: stmnt_skip : LBRACE { pSelector->push("skip_lex"); } skip_stmt_brace { pSelector->pop(); } ; skip_stmt_brace : ( STRING_SKIP | LBRACE skip_stmt_brace )* RBRACE ; This procedure works almost well. It changes to the second lexer and returns after the end key to the first lexer. But after that, when the parser tries to get the next token from the input stream,    More>>

Hi,


I want to create a parser, which change after special keys to a lexer. This second lexer
is used to skip all input tokens until an end key will be recognized.


I defined the following parser rules:



			
stmnt_skip
:
LBRACE { pSelector->push("skip_lex"); }
skip_stmt_brace { pSelector->pop(); }
;

skip_stmt_brace
:
(
STRING_SKIP
| LBRACE skip_stmt_brace
)*
RBRACE
;


This
procedure works almost well. It changes to the second lexer and returns after
the end key to the first lexer. But after that, when the parser tries to get
the next token from the input stream, it gets the first token, which occurs in
the input stream after the key to start the second lexer. While getting the
next token after returning from the second lexer with LA(), the main lexer gets
a token, which is still in monitoring from the text before switching to the
second lexer.


I tried
instead of simple switching to a second lexer to define a special parser with
an owned lexer, but this gives the same results.


How I can
prevent this behavior and reset the monitored queue of tokens?

   <<Less
About | Sitemap | Contact