[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: States in grammar



Hi Roger,

Please do not write messages in HTML format; HTML is for http, not for smtp...

See below.

Roger Pomeroy wrote:
<P>After reading the manual for SableCC, and playing around a bit, I have
a question about the use of "states".&nbsp; In particular, can you have more
than one state active at a time?&nbsp;If so,&nbsp;can you transition from more
than one state?&nbsp; That is, would something like {bol-&gt;inline,
otherstate-&gt;newstate}&nbsp; be a legal specification that would transition
from both bol and otherstate ?</P>

There is a single "state" variable per lexer, so the lexer is always in one
and only one state.

Now, nothing prevents you, using a custom lexer overriding the filter method,
from managing a "stack" of states, so that the lexer returns to "previous" state.

You can specify different transitions for distinct states.

Lexer states work (currently) similarly to the states of traditional lexer tools
Flex and Lex.

Etienne
--
Etienne M. Gagnon, Ph.D.             http://www.info.uqam.ca/~egagnon/
SableVM:                                       http://www.sablevm.org/
SableCC:                                       http://www.sablecc.org/