Package org.jnode.shell.syntax

Examples of org.jnode.shell.syntax.MuBackReference


        new MuAlternation(new MuSymbol("hi"), null);
    }

    @Test
    public void testBackReferenceConstructor() {
        new MuBackReference("hi");
        try {
            new MuBackReference(null);
            Assert.fail("expected NPE");
        } catch (NullPointerException ex) {
            // expected
        }
        try {
            new MuBackReference("");
            Assert.fail("expected IAE");
        } catch (IllegalArgumentException ex) {
            // expected
        }
    }
View Full Code Here


        }
    }

    @Test
    public void testResolveBackReferences() {
        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);

        try {
            syntax = new MuAlternation("root", new MuBackReference("foo"), null);
            syntax.resolveBackReferences();
            Assert.fail("expected SFE");
        } catch (SyntaxFailureException ex) {
            // expected
        }
View Full Code Here

                new MuSymbol("l2", "hi"), new MuSymbol("mum")).format());
    }

    @Test
    public void testFormat2() {
        MuSyntax syntax = new MuAlternation("root", new MuBackReference("root"), null);
        Assert.assertEquals("<root> ::= ( <[root]> |  )\n<[root]> ::= <root>", syntax.format());
        syntax.resolveBackReferences();
        Assert.assertEquals("<root> ::= ( <root> |  )", syntax.format());
    }
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

        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

        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

        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.MuBackReference

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.