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

stack for lexer states?



I have a grammar where there are lexer states which effectively share
common "substates". What seems most convenient is to express this along
the lines of (my own not-so-beautiful syntax)

{a -> b} t1 = 'foo';
{c -> b} t3 = 'erp';
{b -> $pop$} t2 = 'bar';

The idea being, that upon encountering token t2, the lexer returns to
its previous state, either a or c in the above example. This kind of
functionality becomes more useful when such stacks of lexer states gets
deeper. Without a stack, I've ended up essentially duplicating several
states, and the grammar exploded a bit in size.

Is there anything like this in the development versions of sablecc?
Or, alternatively, is there another approach I could take in writing the grammar?

jay