|Flex and EOF firstname.lastname@example.org (Matteo Corti) (2006-04-08)|
|Re: Flex and EOF email@example.com (Chris Dodd) (2006-04-09)|
|Re: Flex and EOF firstname.lastname@example.org (Russ Cox) (2006-04-09)|
|Re: Flex and EOF email@example.com (Michael Tiomkin) (2006-04-09)|
|Re: Flex and EOF DrDiettrich@compuserve.de (Hans-Peter Diettrich) (2006-04-10)|
|Re: Flex and EOF firstname.lastname@example.org (Matteo Corti) (2006-04-12)|
|Re: Flex and EOF email@example.com (Ira Baxter) (2006-04-12)|
|From:||"Ira Baxter" <firstname.lastname@example.org>|
|Date:||12 Apr 2006 22:44:59 -0400|
|Posted-Date:||12 Apr 2006 22:44:59 EDT|
"Hans-Peter Diettrich" <DrDiettrich@compuserve.de> wrote in message
> Matteo Corti wrote:
> > 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.
> This is one of the reasons why e.g. C syntax (of the preprocessor)
> requires that source files must end with a newline character. >
Yes, the standard requires it. But, it isn't enforced. Almost all
the C/C++ compilers we encounter (e.g., have a dialect to process that
compiler source code) allow the preprocessor directive to simply end,
without a newline, commonly seen in the standard "don't include me
twice" idiom as follows:
Many other languages appear to require complete lines in the abstract.
Almost none of the implementations seem to do so. For some langauges,
you actually have to preserve the fact that the last line does NOT
have a newline. (PHP is a particularly egregious example of this).
Ira Baxter, CTO
Return to the
Search the comp.compilers archives again.