Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!cmcl2!rutgers!rochester!PT!k.gp.cs.cmu.edu!bww From: bww@k.gp.cs.cmu.edu (Bradley White) Newsgroups: comp.lang.c Subject: Re: whats wrong with this lex grammer(sic)? (help) Message-ID: <1238@k.gp.cs.cmu.edu> Date: Fri, 25-Sep-87 19:19:06 EDT Article-I.D.: k.1238 Posted: Fri Sep 25 19:19:06 1987 Date-Received: Sun, 27-Sep-87 04:56:59 EDT References: <443@aucs.UUCP> <8765@mimsy.UUCP> Distribution: na Organization: Carnegie-Mellon University, CS/RI Lines: 17 Summary: correct lex expression for (*...*) comments 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 +1-412-268-3060 CMU Computer Science Department 40 26'33"N 79 56'48"W