Re: Lex and Start Conditions (Peter Moore)
Thu, 24 Jan 91 22:48:14 GMT

          From comp.compilers

Related articles
Lex and Start Conditions (1991-01-24)
Re: Lex and Start Conditions (1991-01-24)
Re: Lex and Start Conditions (1991-01-24)
| List of all articles for this month |

Newsgroups: comp.compilers
From: (Peter Moore)
Keywords: lex
Organization: Objectivity Inc.
References: <>
Date: Thu, 24 Jan 91 22:48:14 GMT

In article <>, (Jonathan Eifrig) writes:
|> This works great, except that the automaton has to be started up in the
|> correct (meta) state (in this case, NORM). What is the best way to do this?
This (along with the documentation) are my two biggest complaints with lex.
Here is my solution (with minor flame intact).

Peter Moore

. |
\n {
* Lex has the misfeature that all unlabeled rules are
* always active. This makes interference between labeled
* and unlabeled rules a big problem. To overcome this,
* every rule is labeled, with the normal state being
* NORMAL_MODE. To get ourselves into NORMAL_MODE at the
* start, we use this rule that matches any character. It
* simply switches to NORMAL_MODE and pushes back the
* character that triggered it. Anytime after, this rule
* is shielded by .|\n rules in all the other modes.

NLSTATE; /* otherwise beginning of line rules won't work */
[Should work, but I still like exclusive start states in flex. -John]

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.