Related articles |
---|
Lex and Start Conditions eifrig@server.cs.jhu.edu (1991-01-24) |
Re: Lex and Start Conditions bliss@sp64.csrd.uiuc.edu (1991-01-24) |
Re: Lex and Start Conditions peter@objy.com (1991-01-24) |
Newsgroups: | comp.compilers |
From: | bliss@sp64.csrd.uiuc.edu (Brian Bliss) |
Keywords: | lex |
Organization: | Center for Supercomputing Research and Development |
References: | <eifrig.664691313@voronoi.cs.jhu.edu> |
Date: | Thu, 24 Jan 91 21:54:49 GMT |
To make you lexer start out in a non-default start condition,
just write a routine lex_init (), and put it in the routines
section of the lex file:
void lex_init () { BEGIN STATE; }
then call lex_init () from the main program before parsing.
these's no reason it hash to be in the main program.
bb
P.S. You wouldn't want to use the undocumented INITIAL start condition.
Even if you are in the COMMENT start condition, rules which have
INITIAL start condition will still be recognized. Then,
lex will try to break up the inside of your comments into tokens
before it realizes that the entire comment is a longer token itself,
and chooses this based on the fact that it is longer. all of this
makes the lexer take up much more space: a simple pascal lexer I wrote,
using the INITIAL start condition for normal code (idents, etc),
produced a 300K object file, but when I added the NORMAL start condition
to every rule which had the INITIAL start condition, the object
shrunk to 30K!
bb
[From bliss@sp64.csrd.uiuc.edu (Brian Bliss)]
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.