Menu

Parsing problem

Help
2003-03-14
2003-03-14
  • Nicolas Capens

    Nicolas Capens - 2003-03-14

    Hi Alec,

    I have some parsing code that looks like below. It is used for masking x, y, z and w components of a 4D vector:

            <DOT> {...}

            (
                (<X> {...})
                (<Y> {...})?
                (<Z> {...})?
                (<W> {...})?
            )
                |
            (
                (<Y> {...})
                (<Z> {...})?
                (<W> {...})?
            )
                |
            (
                (<Z> {...})
                (<W> {...})?
            )
                |
            (
                (<W> {.})
            )

    The problem is that when it finds the DOT, it also wants to consume a X token. This isn't correct since this grammar should also accept code like ".yw", but then it throws a parsing error.

    I probably defined this wrongly?

     
    • Nicolas Capens

      Nicolas Capens - 2003-03-14

      My error, sorry!

      I forgot about the operator precedence rules, some extra parentheses solved it...

      CppCC rocks!

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.