@Test
public void testStatelessParsing4() throws NoTokensAvailableException, CommandSyntaxException {
// <root> ::= 'b' | ( 'a' <root> )
MuSyntax syntax =
new MuAlternation("root", new MuSymbol("b"), new MuSequence(new MuSymbol("a"),
new MuBackReference("root")));
MuParser parser = new MuParser();
CommandLine cl;
cl = new CommandLine(new String[] {"b"});
parser.parse(syntax, null, cl.tokenIterator(), null);
try {
cl = new CommandLine(new String[] {"a", "b"});
parser.parse(syntax, null, cl.tokenIterator(), null);
Assert.fail("expected SFE");
} catch (SyntaxFailureException ex) {
// expected
}
syntax.resolveBackReferences();
cl = new CommandLine(new String[] {"a", "b"});
parser.parse(syntax, null, cl.tokenIterator(), null);
cl = new CommandLine(new String[] {"a", "a", "b"});
parser.parse(syntax, null, cl.tokenIterator(), null);