Re: Flex and Lex interpreting regex differently

"Joel E. Denny" <jdenny@ces.clemson.edu>
Mon, 13 Oct 2008 11:36:20 -0400 (EDT)

          From comp.compilers

Related articles
Flex and Lex interpreting regex differently mjmjenks@gmail.com (2008-10-13)
Re: Flex and Lex interpreting regex differently jdenny@ces.clemson.edu (Joel E. Denny) (2008-10-13)
Re: Flex and Lex interpreting regex differently mjmjenks@gmail.com (2008-10-13)
| List of all articles for this month |
From: "Joel E. Denny" <jdenny@ces.clemson.edu>
Newsgroups: comp.compilers
Date: Mon, 13 Oct 2008 11:36:20 -0400 (EDT)
Organization: Compilers Central
References: 08-10-018
Keywords: lex
Posted-Date: 13 Oct 2008 12:45:48 EDT

On Mon, 13 Oct 2008 mjmjenks@gmail.com wrote:
> It looks like I'm having an issue with the portability of one of my
> regular expressions.


> ScaleFactor [ED]([\+\-]?){digit}+


Rewrite as:


    ScaleFactor ([ED]([\+\-]?){digit}+)


Flex adds these parentheses for you. Lex does not.


> ({digit}+)[\.]({digit}+)({ScaleFactor}?) {printf("Real number
> token");};


The difference is whether that "?" after the "{ScaleFactor}" applies to
the "{digit}+" at the end of "{ScaleFactor}" or to all of "{ScaleFactor}".


Post a followup to this message

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