help-flex
[Top][All Lists]
Advanced

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

Re: Flex vs. POSIX 1003.2-1992 repeat operator {} precedence


From: Casey Leedom
Subject: Re: Flex vs. POSIX 1003.2-1992 repeat operator {} precedence
Date: Fri, 26 Apr 2002 13:48:46 -0700

| Date:  Fri, 26 Apr 2002 13:37:46 -0700
| From:  Vern Paxson <address@hidden>
| 
| > It appears that Vern's intent was to conform to POSIX, giving priority to
| > POSIX conformance in cases where lex and POSIX diverge.
| 
| It was more like, (1) I thought lex's precedence rule was really a bad idea,
| and (2) I was delighted when the POSIX interpretation appeared to align with
| the more rational precedence rule used by flex.  Had I realized it didn't, I
| would've fought against it while the POSIX standard was being finalized (as
| I did for a number of other issues).

  By the way, here's the section of POSIX 1003.2-1992 dealing with this
issue:

    The order of precedence given to EREs for lex differs from that
    specified in Table 2-14.  The order of precedence for lex shall be as
    shown in Table A-3, from high to low.

    NOTE: The escaped characters entry is not meant to imply that these are
    operators, but they are included in the table to show their
    relationships to the true operators.  The start condition, trailing
    context, and the anchoring notations have been omitted from the table
    because of placement restrictions described in the subclause; they can
    only appear at the beginning or ending of an ERE.

                    Table A-3 -- lex ERE Precedence
    +---------------------------------------------------------------+
    | Collation-related bracket symbls   | [= =]  [: :]  [. .]      |
    | Escaped characters                 | \<special character>     |
    | Bracket expression                 | [ ]                      |
    | Quoting                            | "..."                    |
    | Grouping                           | ( )                      |
    | Definition                         | {name}                   |
    | Single-character ERE duplication   | * + ?                    |
    | Concatenation                      |                          |
    | Interval expression                | {m, n}                   |
    | Alternation                        | |                        |
    +---------------------------------------------------------------+

  Also note that this is lex's ERE precedence rules.  flex is out of
conformance here.

  The fix to parse.y to follow this precedence is trivial and I've already
done that and tested the result.  Putting in an option to do either
precedence based on a command line switch is more invasive and somewhat
kludgey but I'm making forward progress ...

Casey



reply via email to

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