Hello,
We are trying to implement a grammar with sslr and our unit tests are failing when trying to match some tokens.
Stack trace is ;
org.sonar.sslr.grammar.GrammarException: The inner part of ZeroOrMore and OneOrMore must not allow empty matches
at org.sonar.sslr.internal.vm.Instruction$CommitVerifyInstruction.execute(Instruction.java:279)
at org.sonar.sslr.internal.vm.Machine.execute(Machine.java:162)
at org.sonar.sslr.internal.vm.Machine.execute(Machine.java:105)
at org.sonar.sslr.internal.vm.Machine.parse(Machine.java:83)
at org.sonar.sslr.parser.ParseRunner.parse(ParseRunner.java:46)
at org.sonar.sslr.tests.RuleAssert.matches(RuleAssert.java:81)
We assume we are not doing correct usage for method zeroOrMore
of org.sonar.sslr.grammar.GrammarBuilder
But what does the message mean exactly ?
If it helps we have grammar rule key defined like
b.rule(TOKEN_STRUCTURE).is(b.firstOf(
b.sequence(“(”, b.zeroOrMore(TOKEN), “)”),
b.sequence(“[”, b.zeroOrMore(TOKEN), “]”),
b.sequence(“{”, b.zeroOrMore(TOKEN), “}”)));
where TOKEN is another (non empty) rule key
the message The inner part of ZeroOrMore and OneOrMore must not allow empty matches
is obscure, can you help us understand why is that ?
(We want the rule to match strings like (toto)
[toto]
or {toto}
)
Thanks
JPK