Package org.jnode.shell.syntax

Examples of org.jnode.shell.syntax.MuSequence


    }

    @Test
    public void testStatelessParsing2() throws NoTokensAvailableException, CommandSyntaxException {
        // <start> ::= 'a' 'b'
        MuSyntax syntax = new MuSequence(new MuSymbol("a"), new MuSymbol("b"));
        MuParser parser = new MuParser();
        CommandLine cl;

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


    @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"});
View Full Code Here

    @Test
    public void testStatelessParsing5() throws NoTokensAvailableException, CommandSyntaxException {
        // <root> ::= ( 'a' <root> ) | 'b'
        MuSyntax syntax =
                new MuAlternation("root", new MuSequence(new MuSymbol("a"), new MuBackReference(
                        "root")), new MuSymbol("b"));
        MuParser parser = new MuParser();
        CommandLine cl;

        syntax.resolveBackReferences();
View Full Code Here

    @Test
    public void testStatelessParsing6() throws NoTokensAvailableException, CommandSyntaxException {
        // <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();
View Full Code Here

    @Test
    public void testPathological() throws NoTokensAvailableException, CommandSyntaxException {
        // Pathological grammar.
        // <root> ::= 'b' | ( <root> <root> )
        MuSyntax syntax =
                new MuAlternation("root", new MuSymbol("b"), new MuSequence(new MuBackReference(
                        "root"), new MuBackReference("root")));
        MuParser parser = new MuParser();
        CommandLine cl;

        syntax.resolveBackReferences();
View Full Code Here

        }
    }

    @Test
    public void testSequenceConstructor() {
        new MuSequence(new MuSymbol("hi"), new MuSymbol("mom"));
        try {
            new MuSequence(new MuSymbol("hi"), null);
            Assert.fail("expected NPE");
        } catch (NullPointerException ex) {
            // expected
        }
    }
View Full Code Here

        MuSyntax syntax = new MuAlternation("root", new MuBackReference("root"), null);
        syntax.resolveBackReferences();
        Assert.assertEquals(((MuAlternation) syntax).getAlternatives()[0], syntax);

        syntax =
                new MuAlternation("root", new MuSequence(new MuBackReference("root"),
                        new MuBackReference("root")), null);
        syntax.resolveBackReferences();
        MuSyntax[] tmp = ((MuAlternation) syntax).getAlternatives();
        Assert.assertEquals(((MuSequence) tmp[0]).getElements()[0], syntax);
        Assert.assertEquals(((MuSequence) tmp[0]).getElements()[1], syntax);
View Full Code Here

        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"),
                new MuSymbol("mum")).format());
        Assert.assertEquals("<l1> ::= 'hi' 'mum'", new MuSequence("l1", new MuSymbol("hi"),
                new MuSymbol("mum")).format());
        Assert.assertEquals("<l1> ::= <l2> 'mum'\n<l2> ::= 'hi'", new MuSequence("l1",
                new MuSymbol("l2", "hi"), new MuSymbol("mum")).format());

        Assert.assertEquals("<*Start*> ::= ( 'hi' | 'mum' )", new MuAlternation(new MuSymbol("hi"),
                new MuSymbol("mum")).format());
        Assert.assertEquals("<*Start*> ::= ( 'hi' |  )",
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

        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

TOP

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

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.