|In lex, how do I begin in a state?? email@example.com (James A. Cadwell) (1992-11-21)|
|Re: In lex, how do I begin in a state?? firstname.lastname@example.org (1992-11-22)|
|Re: In lex, how do I begin in a state?? email@example.com (1992-11-25)|
|From:||"James A. Cadwell" <firstname.lastname@example.org>|
|Date:||Sat, 21 Nov 1992 03:29:14 GMT|
|Keywords:||lex, question, comment|
In lex, one uses BEGIN STATE-NAME in an action to place lex in a
state. My question is: how do I begin in a state?? That is, have
a state in effect before any input is read.
Jim Cadwell email@example.com
[In short, you have to execute a BEGIN before the lexer starts scanning.
Code put at the front of the rules section is run whenever you call yylex(),
so you could do something like this:
static int first_time = 1;
first_time = 0;
The new version of O'Reilly's lex&yacc, much of which I wrote, explains this
in more detail. -John]
Return to the
Search the comp.compilers archives again.