Related articles |
---|
In lex, how do I begin in a state?? cadwell@seattleu.edu (James A. Cadwell) (1992-11-21) |
Re: In lex, how do I begin in a state?? eifrig@beanworld.cs.jhu.edu (1992-11-22) |
Re: In lex, how do I begin in a state?? tamdhu.ohm.york.ac.uk!rog@ohm.york.ac.uk (1992-11-25) |
Newsgroups: | comp.compilers |
From: | tamdhu.ohm.york.ac.uk!rog@ohm.york.ac.uk (Roger Peppe) |
Organization: | Electronics Department, University of York, UK |
Date: | Wed, 25 Nov 1992 15:22:08 GMT |
References: | 92-11-129 |
Keywords: | lex, comment |
Relevant to this discussion is an issue that I've wondered about for a
while. Is it documented that the state is an integer ? For instance, I've
written code several times that looks like something this :
<s1,s2,s3>"/*" BEGIN comment;
<comment>"*/" BEGIN currstate;
<comment>. ;
<s1>state2 { BEGIN state2; currstate = state2; }
<s2>state1 { BEGIN state1; currstate = state1; }
... etc.
It's very useful to be able to do this, especially if one has many
distinct states, but one common state that can be invoked from any of
them. It makes most difference when pushing the limits of the lex
parameters, so a lot of duplicate code can be saved. But how portable is
it ?
rog. (rog@ohm.york.ac.uk)
[It's quite portable. All versions of lex that I've seen in fact define
the state names as small integers. Posix says that lex can define the
arguments to BEGIN any way it wants, but the initial state has to be
named 0 and INITIAL. -John]
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.