[comp.lang.c] whats wrong with this lex grammer

bww@k.gp.cs.cmu.edu (Bradley White) (09/26/87)

In article <8765@mimsy.UUCP>, chris@mimsy.UUCP (Chris Torek) writes:
> The expression
> 
> 	\(\*(\*[^)]|[^*])*\*+\)
> 
> should work.

Clearly the above expression is wrong if Lex selects the longest
matching pattern (as it does).  Consider, for example, the string
"(***)*)".  If Lex took the shortest pattern then \(\*.*\*\) would
suffice.  A correct expression is

	\(\*[^*]*\*+([^*)][^*]*\*+)*\)

-- 
Bradley White <bww@cs.cmu.edu>         +1-412-268-3060
CMU Computer Science Department  40 26'33"N 79 56'48"W