@Test
public void testStatefullParsing6() throws NoTokensAvailableException, CommandSyntaxException {
EnumArgument<Big> bigArg = new BigArgument("bigArg", Argument.MULTIPLE);
EnumArgument<Small> smallArg = new SmallArgument("smallArg", Argument.MULTIPLE);
IntegerArgument intArg = new IntegerArgument("intArg", Argument.MULTIPLE);
ArgumentBundle bundle = new ArgumentBundle(intArg, smallArg, bigArg);
// <root> ::= ( ( <<intArg>> <root> ) | ( <<bigArg>> <<smallArg>> ) ) |
// ( ( <<intArg>> <root> ) | <<bigArg>> ) )
MuSyntax syntax = new MuAlternation("root", new MuAlternation(new MuSequence(new MuArgument("intArg"),
new MuBackReference("root")), new MuSequence(new MuArgument("bigArg"), new MuArgument("smallArg"))),
new MuAlternation(new MuSequence(new MuArgument("intArg"), new MuBackReference("root")),
new MuArgument("bigArg")));
syntax.resolveBackReferences();
MuParser parser = new MuParser();
CommandLine cl;
cl = new CommandLine(new String[] {"BIG"});
parser.parse(syntax, null, cl.tokenIterator(), bundle);
Assert.assertEquals(1, bigArg.getValues().length);
Assert.assertEquals(0, smallArg.getValues().length);
Assert.assertEquals(0, intArg.getValues().length);
cl = new CommandLine(new String[] {"1", "LARGE"});
parser.parse(syntax, null, cl.tokenIterator(), bundle);
Assert.assertEquals(1, bigArg.getValues().length);
Assert.assertEquals(0, smallArg.getValues().length);
Assert.assertEquals(1, intArg.getValues().length);
cl = new CommandLine(new String[] {"1", "2", "BIG"});
parser.parse(syntax, null, cl.tokenIterator(), bundle);
Assert.assertEquals(1, bigArg.getValues().length);
Assert.assertEquals(0, smallArg.getValues().length);
Assert.assertEquals(2, intArg.getValues().length);
cl = new CommandLine(new String[] {"1", "2", "3", "BIG", "SMALL"});
parser.parse(syntax, null, cl.tokenIterator(), bundle);
Assert.assertEquals(1, bigArg.getValues().length);
Assert.assertEquals(1, smallArg.getValues().length);
Assert.assertEquals(3, intArg.getValues().length);
try {
cl = new CommandLine(new String[] {"1", "2", "TINY"});
parser.parse(syntax, null, cl.tokenIterator(), bundle);
Assert.fail("expected SEE");