Closed bkovitz closed 5 years ago
Here's a workaround:
#lang brag
start : elem*
elem : THING "(" arg ")"
| THING "(" arg ("," arg)+ ")" ; In lieu of * (i.e. zero-or-more)
arg : IDENTIFIER
| IDENTIFIER ":" IDENTIFIER
Does this grammar fix the problem for you?
#lang brag
start : elem*
elem : THING "(" arg ("," arg)* ")"
arg : IDENTIFIER [":" IDENTIFIER]
(If so it doesn’t negate the possibility of a bug, but I am interested in collecting information about its behavior)
Nope, same error.
That’s strange, because it does fix the parse error for me. In any case, I can reproduce the original error (and have simplified it further). Also, I have reproduced it in the original ragg
package that brag
is based on, so it may take a little excavation to sort out.
Making a note of the minimal error case:
#lang br
@module/lang[parser]{
#lang brag
foo : ( (X | X Y) A* )*
}
(require 'parser)
(parse (list "X" "Y" "X"))
I just tried your alternate grammar with arg : IDENTIFIER [":" IDENTIFIER]
again and it does work. Sorry, I must have done something wrong when I tried it the first time.
I changed the way the *
quantifier works, which I believe fixes the problem.
In the grammar below, once a
THING
containing the case marked by the comment has matched, the grammar returns an error on the nextTHING
.I can't figure out how to attach a file in GitHub, but you can reproduce the error by pasting the text above into a file called
bug.brag
and the text below into a file calledbug.rkt
and running the latter.