Re: Columns in flex.

robertsw@agcs.com (Wallace Roberts)
Fri, 27 Jan 1995 05:06:49 GMT

          From comp.compilers

Related articles
Columns in flex. Regan.Russell@jcu.edu.au (Regan Russell) (1995-01-23)
Re: Columns in flex. C.A.Elliott@dcs.warwick.ac.uk (1995-01-27)
Re: Columns in flex. c1veeru@watson.ibm.com (Virendra K. Mehta) (1995-01-27)
Re: Columns in flex. robertsw@agcs.com (1995-01-27)
Re: Columns in flex. schrod@iti.informatik.th-darmstadt.de (1995-01-31)
Re: Columns in flex. flisakow@cs.wisc.edu (1995-01-28)
| List of all articles for this month |
Newsgroups: comp.compilers
From: robertsw@agcs.com (Wallace Roberts)
Keywords: flex, Cobol
Organization: agcs
References: 95-01-051
Date: Fri, 27 Jan 1995 05:06:49 GMT

Regan Russell <Regan.Russell@jcu.edu.au> writes:
>Q: How do I do column sensitive scanning in flex ?


keep track of the column with each pattern recognized, i.e.:


%{
#define COMMENT_COLUMN 7
int yycolumn = 1;
int yylineno = 1;
%}


...


\* { if ( yycolumn == COMMENT_COLUMN ) ... }
keyword { yycolumn += yyleng; ... }
[ \t]+ { yycolumn += yyleng; ... }
\n { yycolumn = 1; ++yylineno; ... }
. { ++yycolumn; ... }


this should give you a good idea what i mean.


>Q: Or should I write my own scanner ?


i wouldn't recommend it. :-)


gears,
ye wilde ryder
--
robertsw@agcs.com
--


Post a followup to this message

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