help-flex
[Top][All Lists]
Advanced

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

flex: POSIX compatibility bug: matching right parentheses (fwd)


From: Neil Zanella
Subject: flex: POSIX compatibility bug: matching right parentheses (fwd)
Date: Tue, 9 Sep 2003 16:40:48 -0230 (NDT)

Hello,

I think I may have found either a code or documentation
bug in either flex or the POSIX standard concerning whether
or not right parentheses should be escaped by a backslash in
the rules section of lex specifications...

The flex manual states the following in section 0.20
entitled Incompatibilities with lex and POSIX:

"Flex is fully compliant with the POSIX specification,
except when using %pointer..."

On the other hand the POSIX standard at the Open Group's site states:

http://www.opengroup.org/onlinepubs/007904975/utilities/lex.html

"The lex utility shall support the set of extended regular expressions
 (see the Base Definitions volume of IEEE Std 1003.1-2001,
 Section 9.4, Extended Regular Expressions)..."

these are described at the following page:

http://www.opengroup.org/onlinepubs/007904975/basedefs/xbd_chap09.html#tag_09_04

which states the following two things:

"An ordinary character is an ERE that matches itself.
 An ordinary character is any character in the supported character set,
 except for the ERE special characters listed in ERE Special Characters."

"The right-parenthesis shall be special when matched with a preceding
 left-parenthesis, both outside a bracket expression."

This seems to mean that the right parenthesis ')' is not to be considered
a special character and thus needs no backslash in the following lex 
specification:

%{
#include <stdio.h>
%}

%%

) printf("foo!");

%%

int main(void) {
  yylex();
}

Instead flex (version 2.5.4) complains with:

"x.l", line 7: unrecognized rule
"x.l", line 7: unrecognized rule

and requires that the rule be corrected as follows
in order to produce the lex.yy.c file without complaints:

\) printf("foo!");

By enforcing this rule, isn't flex violating the POSIX standard?

Given that flex claims POSIX compliancy, isn't this a bug in flex?

Thank you for your feedback and clarification!

Best Regards,

Neil






reply via email to

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