Re: column position in flex
Attila Csosz <csosz77@axelero.hu> writes:
> How can I get the column position using flex? (for better error handling)
I don't see any obvious way to, which seems a little surprising. You
might try redefining the YY_USER_ACTION macro, though (see
(flex)Miscellaneous in the Info docs):
%{
int line = 0;
int frcol = 0;
int tocol = 0;
#define YY_USER_ACTION { frcol = tocol; tocol += yyleng; }
%}
%%
\n line++; frcol = tocol = 0;
(%option yylineno will keep track of the line number for you, see
(flex)Options, but there's not an equivalent column number option that
I see. Since you need a rule for \n anyways, you might as well track
the line number by hand.)
--
David Maze dmaze@debian.org http://people.debian.org/~dmaze/
"Theoretical politics is interesting. Politicking should be illegal."
-- Abra Mitchell
Reply to: