help-flex
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: flex needs spurious whitespace?


From: Hans-Bernhard Broeker
Subject: Re: flex needs spurious whitespace?
Date: Fri, 28 Sep 2001 12:03:26 +0200 (MET DST)

On Thu, 27 Sep 2001, Clint Jeffery wrote:

> Why does the first version of the whitespace comment eater below pass
> flex with no complaints, while the second one generates errors? 

> --- example flex input (foo.l) below this point.
> %%
> "/*" ([^*] | ("*" / [^/])) * "*/"     {/*do nothing. eat comments*/}
> "/*"([^*]|("*"/[^/]))*"*/"    {/*do nothing. eat comments*/}
                ^---- that's your problem

You'll have to quote that '/'. '/' is a special character in lex patterns,
indicating trailing context. The following, minimally changed rule, at
least parses cleanly:

/*"([^*]|("*/"[^/]))*"*/"

For comparison, here's the rule I use to parse C or C++ comments (for
'cscope', a classical Unix C source code navigation tool):

comment         "/*"([^*]*("*"+[^/])?)*"*/"|"//"[^\n]*\n

-- 
Hans-Bernhard Broeker (address@hidden)
Even if all the snow were burnt, ashes would remain.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]