Regular expressions in Lex.

bill at hao.UUCP bill at hao.UUCP
Tue Jul 22 02:41:30 AEST 1986


I'm trying to use Lex to dig out the OPEN statements in a fortran source file.
Of course, I have to be aware of continuation lines, so I use a regular 
expression (see the example in 1.) to dig out the single continuation line.

	1. ^[^Cc].*open[ ]*\(.*\n[     .].*\)  printf ("%s", yytext);  

This seems to work fine.  But when I try to find multiple continuation lines
with the pattern given in 2., I don't even get the single continuation lines.

        2. ^[^Cc].*open[ ]*\(.*\n[[     .].*[\n\)]]+ printf ("%s", yytext); 

My questions are:
	a) Isn't the r.e. [[     .].*[\n\)]]+ valid?
	b) If it is, what am I doing wrong?  i.e. why don't it work?
	c) Do you have any suggestions on a better reference to Lex than that
	   given in the Unix Programmer's Manual, III, by Lesk and Schmidt?

Thanks in advance for any ideas or suggestions.

							Bill Roberts
							NCAR/HAO
							Boulder, CO
							!hao!bill



More information about the Comp.unix mailing list