// <root> ::= ( ( 'a' <root> ) | ( 'b' 'c' ) ) | ( ( 'a' <root> ) | 'b'
// ) )
MuSyntax syntax = new MuAlternation("root", new MuAlternation(new MuSequence(new MuSymbol("a"),
new MuBackReference("root")), new MuSequence(new MuSymbol("b"), new MuSymbol("c"))),
new MuAlternation(new MuSequence(new MuSymbol("a"), new MuBackReference("root")), new MuSymbol("b")));
MuParser parser = new MuParser();
CommandLine cl;
syntax.resolveBackReferences();
cl = new CommandLine(new String[] {"b"});
parser.parse(syntax, null, cl.tokenIterator(), null);
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);
cl = new CommandLine(new String[] {"a", "a", "b", "c"});
parser.parse(syntax, null, cl.tokenIterator(), null);
try {
cl = new CommandLine(new String[] {"a", "a", "c"});
parser.parse(syntax, null, cl.tokenIterator(), null);
Assert.fail("expected SEE");
} catch (CommandSyntaxException ex) {
// expected
}
}