Ticket #1447 (closed bug: invalid)

Opened 12 years ago

Last modified 10 years ago

[NQP-rx] failure to capture two duplicate subrules in the same rule

Reported by: allison Owned by: pmichaud
Priority: normal Milestone:
Component: nqp Version: 2.0.0
Severity: medium Keywords:
Cc: Language:
Patch status: Platform:

Description

I ran into a problem with nqp-rx grammars in a mini-language I'm working on. Looks like it might be a bug in nqp-rx, though I'm always suspicious that cases like this might be a bug in the language grammar (if it's the latter, you can close the ticket, since the language has switched to true operator precedence parsing).

With two identical subrules matching in a rule, only the second result is captured in the parse tree. So a rule like:

    <IF> <expression> <relation> <expression>

Matches as:

              PMC 'Regex;Match' => "IF 2 < 1\n..." @ 38 {
                        <relation> => PMC 'Regex;Match' => "<" @ 43
                        <IF> => PMC 'Regex;Match' => "IF" @ 38
                        <expression> => PMC 'Regex;Match' => "1\n  " @ 45 {
                            [...]
                        }

I was hoping to be able to duplicate the problem in an isolated case, but a simplified grammar like the following creates an array of <foo> as you would expect.

token TOP { <foo> <bar> <foo> }
rule foo { 'foo' | 'oof' }
token bar { 'bar' }

So far, I've only been able to duplicate the bug with the full language grammar, so, I've put a copy of the language at that version up on  http://pub.lohutok.net/nqp/camle-0.0.1b-ar9319.tar.gz. Run 'make parrot', 'make', and then './camle --target=parse twosubrule.le' to produce the output above.

Change History

  Changed 11 years ago by jkeenan

  • owner set to pmichaud
  • component changed from none to nqp

in reply to: ↑ description   Changed 11 years ago by pmichaud

  • status changed from new to assigned

Replying to allison:

So far, I've only been able to duplicate the bug with the full language grammar, so, I've put a copy of the language at that version up on  http://pub.lohutok.net/nqp/camle-0.0.1b-ar9319.tar.gz. Run 'make parrot', 'make', and then './camle --target=parse twosubrule.le' to produce the output above.

I just tried this locally and I correctly get the array for the expression:

                <statement> => ResizablePMCArray (size:1) [
                    PMC 'Regex;Match' => "IF 2 < 1\n  BEGIN\n    write('ok 1');\n    writeln;\n  END" @ 38 {
                        <relation> => PMC 'Regex;Match' => "<" @ 43
                        <IF> => PMC 'Regex;Match' => "IF" @ 38
                        <expression> => ResizablePMCArray (size:2) [
                            PMC 'Regex;Match' => "2 " @ 41 {
                            ... 
                            },
                            PMC 'Regex;Match' => "1\n  " @ 45 {
                            ...

So, I'm left guessing that it's something about the particular machine or Parrot build that caused the error -- I'm unable to reproduce it here.

Pm

  Changed 10 years ago by pmichaud

  • status changed from assigned to closed
  • resolution set to invalid

Marking ticket as invalid -- unable to reproduce the reported error.

Pm

Note: See TracTickets for help on using tickets.