Re: Flex and EOF

"Michael Tiomkin" <>
9 Apr 2006 17:26:37 -0400

          From comp.compilers

Related articles
Flex and EOF (Matteo Corti) (2006-04-08)
Re: Flex and EOF (Chris Dodd) (2006-04-09)
Re: Flex and EOF (Russ Cox) (2006-04-09)
Re: Flex and EOF (Michael Tiomkin) (2006-04-09)
Re: Flex and EOF (Hans-Peter Diettrich) (2006-04-10)
Re: Flex and EOF (Matteo Corti) (2006-04-12)
Re: Flex and EOF (Ira Baxter) (2006-04-12)
| List of all articles for this month |

From: "Michael Tiomkin" <>
Newsgroups: comp.compilers
Date: 9 Apr 2006 17:26:37 -0400
References: 06-04-035
Keywords: lex, comment
Posted-Date: 09 Apr 2006 17:26:37 EDT

Matteo Corti wrote:
> Hi,
> I have a rule in my lexer to skip shell-like comments:
> #.*$ /* skip comments */
> which works just fine if there is \n at the end of the line.
> If the comment is in the last line wich is terminated by EOF the rule
> obviously fails.
> I tried something like:
> #.*<<EOF>>
> but flex complains about an "unrecognized rule". Any hint?

    The easiest way is to introduce the new state, shell_comment, switch
to it on a '#', do nothing on ., and switch back on a $ or '\n'.

[That'd work, but I like #.* with separate \n better. -John]

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.