[net.unix-wizards] Lex query

ondich (06/14/82)

Our v7 Lex is recognizing  "^"  as beginning of line
in the rules section, but not in the definitions section.
For example:

name		^[a-zA-Z]
%%
{name}		{action...}

is not performing the action for lines beginning with a letter, 
but

%%
^[a-zA-Z]	{action...}

is working fine.  Though not disastrous (I can simply use
the second form), this problem has led to some aesthetically
unpleasant code.  Is the problem typical?  Is it a bug?
Perhaps a feature?  Any enlightenment would be appreciated.

			Thanks,

				Jeff Ondich
				ihps3!stolaf!ondich

lacasse@RAND-UNIX@sri-unix (07/29/82)

Date: Sunday, 27 Jun 1982 15:55-PDT
Re:
    Our v7 Lex is recognizing  "^"  as beginning of line
    in the rules section, but not in the definitions section.

Put (parenthesis) around your definition, viz:

     name            (^[a-zA-Z])
     %%
     {name}          {action...}

In fact, it is good practice to put parenthesis around all lex definitions
if you wish to avoid this and other bugs.  More serious are certain bugs
surrounding the use of yyless, REJECT, and look-aheads, when more than one
of these three act on the same piece of text.  Lex can delete one character
of input text.  Also, ^text will not match at the beginning of the file.
Would anyone who has debugged these please contact me.

	  Mark LaCasse
	  Rand Corporation
	  1700 Main Street
	  Santa Monica, CA 90406
	    213/393-0411