Ticket #1447 (closed bug: invalid)
[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.
