[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
yy_current_state, stuff
From: |
Jordan DeLong |
Subject: |
yy_current_state, stuff |
Date: |
Thu, 15 Mar 2001 10:48:53 +0000 |
User-agent: |
Mutt/1.2.5i |
Hello,
in attempting to use a flex-created lexical scanner for syntax highliting in a
text editor I'm writing I ran into a problem;
I wanted to be able to keep the exact state of the scanner and go back to the
editing and then use that state when I get back; this would let me save the last
line that had a valid state and the state number on that line, so I don't have
to
scan the whole file every time. to do this I need to be able to set the
yy_current_state variable from my .l file. unfortunatly this var gets set up
at the top of the main while (1) loop, which is of course after the YY_USER_INIT
and before the YY_DO_BEFORE_ACTION macros that the user gets to use. This means
there is no opportunity for me to set the yy_current_state to my saved value,
so I propose a new YY macro for this purpose:
instead of something like so:
yy_current_state = yy_start;
yy_current_state += YY_AT_BOL();
yy_state_ptr = yy_state_buf;
*yy_state_ptr++ = yy_current_state;
that could be put in an
#ifndef YY_USER_STATE_INIT
/* that stuff
#else
YY_USER_STATE_INIT
#endif
I would be willing to add this feature to flex if you guys don't have the time,
but of course, if there's a better way to do this, please let me know.
-Jordan
- yy_current_state, stuff,
Jordan DeLong <=