Package org.jnode.shell.syntax

Examples of org.jnode.shell.syntax.MuArgument


        }
    }

    @Test
    public void testMuArgumentConstructor() {
        new MuArgument("arg1");
        new MuArgument("label", "arg1", 0);

        try {
            new MuArgument(null, null, 0);
            Assert.fail("expected NPE");
        } catch (NullPointerException ex) {
            // expected
        }
        try {
            new MuArgument(null, "", 0);
            Assert.fail("expected IAE");
        } catch (IllegalArgumentException ex) {
            // expected
        }
        try {
            new MuArgument("", "arg1", 0);
            Assert.fail("expected IAE");
        } catch (IllegalArgumentException ex) {
            // expected
        }
    }
View Full Code Here


        }
    }

    @Test
    public void testFormat() {
        Assert.assertEquals("<*Start*> ::= <<arg1>>", new MuArgument("arg1").format());
        Assert.assertEquals("<l1> ::= <<arg1>>", new MuArgument("l1", "arg1", 0).format());

        Assert.assertEquals("<*Start*> ::= 'hi'", new MuSymbol("hi").format());
        Assert.assertEquals("<l1> ::= 'hi'", new MuSymbol("l1", "hi").format());

        Assert.assertEquals("<*Start*> ::= 'hi' 'mum'", new MuSequence(new MuSymbol("hi"),
View Full Code Here

    public void testStatefullParsing1() throws NoTokensAvailableException, CommandSyntaxException {
        IntegerArgument intArg = new IntegerArgument("intArg", Argument.MULTIPLE);
        ArgumentBundle bundle = new ArgumentBundle(intArg);

        // <start> ::= <<intArg>>
        MuSyntax syntax = new MuArgument("intArg");
        MuParser parser = new MuParser();
        CommandLine cl;

        cl = new CommandLine(new String[] {"1"});
View Full Code Here

        IntegerArgument intArg = new IntegerArgument("intArg", Argument.MULTIPLE);
        FileArgument fileArg = new FileArgument("fileArg", Argument.MULTIPLE);
        ArgumentBundle bundle = new ArgumentBundle(intArg, fileArg);

        // <start> ::= <<intArg>> <<fileArg>>
        MuSyntax syntax = new MuSequence(new MuArgument("intArg"), new MuArgument("fileArg"));
        MuParser parser = new MuParser();
        CommandLine cl;

        cl = new CommandLine(new String[] {"1", "x"});
        parser.parse(syntax, null, cl.tokenIterator(), bundle);
View Full Code Here

        IntegerArgument intArg = new IntegerArgument("intArg", Argument.MULTIPLE);
        FileArgument fileArg = new FileArgument("fileArg", Argument.MULTIPLE);
        ArgumentBundle bundle = new ArgumentBundle(intArg, fileArg);

        // <start> :: = <<intArg>> | <<fileArg>>
        MuSyntax syntax = new MuAlternation(new MuArgument("intArg"), new MuArgument("fileArg"));
        MuParser parser = new MuParser();
        CommandLine cl;

        cl = new CommandLine(new String[] {"1"});
        parser.parse(syntax, null, cl.tokenIterator(), bundle);
View Full Code Here

        FileArgument fileArg = new FileArgument("fileArg", Argument.MULTIPLE);
        ArgumentBundle bundle = new ArgumentBundle(intArg, fileArg);

        // <root> ::= <<fileArg>> | ( <<intArg>> <root> )
        MuSyntax syntax =
                new MuAlternation("root", new MuArgument("fileArg"), new MuSequence(new MuArgument(
                        "intArg"), new MuBackReference("root")));
        syntax.resolveBackReferences();

        MuParser parser = new MuParser();
        CommandLine cl;
View Full Code Here

        FileArgument fileArg = new FileArgument("fileArg", Argument.MULTIPLE);
        ArgumentBundle bundle = new ArgumentBundle(intArg, fileArg);

        // <root> ::= ( <<intArg>> <root> ) | <<fileArg>>
        MuSyntax syntax =
                new MuAlternation("root", new MuSequence(new MuArgument("intArg"),
                        new MuBackReference("root")), new MuArgument("fileArg"));
        syntax.resolveBackReferences();
        MuParser parser = new MuParser();
        CommandLine cl;

        cl = new CommandLine(new String[] {"x"});
View Full Code Here

        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;
View Full Code Here

TOP

Related Classes of org.jnode.shell.syntax.MuArgument

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.