Change in Token color when entering newline and having lexical states

"Klaus Martinschitz" <[email protected]>
Newsgroups gmane.comp.java.netbeans.modules.openide.devel
Message-ID <[email protected]>
Hello,

I have already implemented lexers and parsers in Netbeans. It's quite easy. However, till now I never had lexers with lexical states. Now, the first time I use a JavaCC Lexer with lexical states, I found a behaviour I can not explain. Let's see an example...

The DSL is defined in that way, that some tokens are identified at the very beginning (its not important what they mean). However, at the end, i.e. after the token rgnr <INTEGER>, every character should be a comment and therfore be gray. I have defined the JavaCC grammar file in that way, if the token rgnr is identified there is a switch to RGNR_STATE. Moreover there are two <INTEGER> tokens defined, one for default and one for RGNR_STATE. If the <INTEGER> for RGNR_STATE is reached, the lexer state is switched to COMMENT_STATE. This works perfectly if the data is loaded (see picture 1).

Now, the problem is, that if I only enter a single carriage return between the comment and the text above, it looks like this (see picture 2).

I suppose that I have to tell the Lexer to "reinit" how do I have to do this?
Thanks a lot for help.

Regards,
Klaus




Attachments: 
http://forums.netbeans.org//files/lexerstateproblempicture1_106.jpg
http://forums.netbeans.org//files/lexerstateproblempicture2_396.jpg
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.