Package org.jnode.shell.syntax

Examples of org.jnode.shell.syntax.MuSymbol


    }

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

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


    }

    @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 testStatelessParsing3() throws NoTokensAvailableException, CommandSyntaxException {
        // <start> :: = 'a' | 'b'
        MuSyntax syntax = new MuAlternation(new MuSymbol("a"), new MuSymbol("b"));
        MuParser parser = new MuParser();
        CommandLine cl;

        cl = new CommandLine(new String[] {"a"});
        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

public class MuSyntaxTest {

    @Test
    public void testMuSymbolConstructor() {
        new MuSymbol("hi");
        new MuSymbol("prod1", "hi");
        try {
            new MuSymbol(null, null);
            Assert.fail("expected NPE");
        } catch (NullPointerException ex) {
            // expected
        }
        try {
            new MuSymbol(null, "");
            Assert.fail("expected IAE");
        } catch (IllegalArgumentException ex) {
            // expected
        }
        try {
            new MuSymbol("", "hi");
            Assert.fail("expected IAE");
        } catch (IllegalArgumentException ex) {
            // expected
        }
    }
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

        }
    }

    @Test
    public void testAlternationConstructor() {
        new MuAlternation(new MuSymbol("hi"), new MuSymbol("mom"));
        new MuAlternation(new MuSymbol("hi"), null);
    }
View Full Code Here

TOP

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

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.