Package org.jnode.shell.bjorne

Examples of org.jnode.shell.bjorne.BjorneTokenizer


        Assert.assertEquals(TOK_END_OF_STREAM, token.getTokenType());
    }

    @Test
    public void testRule7b() throws ShellSyntaxException {
        BjorneTokenizer tokenizer =
                new BjorneTokenizer(
                        "if then else elif fi for done while until case { } ! do in esac a= a=b 1a=b =c");
        BjorneToken token = tokenizer.next(RULE_7b_CONTEXT);
        Assert.assertEquals(TOK_WORD, token.getTokenType());
        token = tokenizer.next(RULE_7b_CONTEXT);
        Assert.assertEquals(TOK_WORD, token.getTokenType());
        token = tokenizer.next(RULE_7b_CONTEXT);
        Assert.assertEquals(TOK_WORD, token.getTokenType());
        token = tokenizer.next(RULE_7b_CONTEXT);
        Assert.assertEquals(TOK_WORD, token.getTokenType());
        token = tokenizer.next(RULE_7b_CONTEXT);
        Assert.assertEquals(TOK_WORD, token.getTokenType());
        token = tokenizer.next(RULE_7b_CONTEXT);
        Assert.assertEquals(TOK_WORD, token.getTokenType());
        token = tokenizer.next(RULE_7b_CONTEXT);
        Assert.assertEquals(TOK_WORD, token.getTokenType());
        token = tokenizer.next(RULE_7b_CONTEXT);
        Assert.assertEquals(TOK_WORD, token.getTokenType());
        token = tokenizer.next(RULE_7b_CONTEXT);
        Assert.assertEquals(TOK_WORD, token.getTokenType());
        token = tokenizer.next(RULE_7b_CONTEXT);
        Assert.assertEquals(TOK_WORD, token.getTokenType());
        token = tokenizer.next(RULE_7b_CONTEXT);
        Assert.assertEquals(TOK_WORD, token.getTokenType());
        token = tokenizer.next(RULE_7b_CONTEXT);
        Assert.assertEquals(TOK_WORD, token.getTokenType());
        token = tokenizer.next(RULE_7b_CONTEXT);
        Assert.assertEquals(TOK_WORD, token.getTokenType());
        token = tokenizer.next(RULE_7b_CONTEXT);
        Assert.assertEquals(TOK_WORD, token.getTokenType());
        token = tokenizer.next(RULE_7b_CONTEXT);
        Assert.assertEquals(TOK_WORD, token.getTokenType());
        token = tokenizer.next(RULE_7b_CONTEXT);
        Assert.assertEquals(TOK_WORD, token.getTokenType());
        token = tokenizer.next(RULE_7b_CONTEXT);
        Assert.assertEquals(TOK_ASSIGNMENT, token.getTokenType());
        token = tokenizer.next(RULE_7b_CONTEXT);
        Assert.assertEquals(TOK_ASSIGNMENT, token.getTokenType());
        token = tokenizer.next(RULE_7b_CONTEXT);
        Assert.assertEquals(TOK_WORD, token.getTokenType());
        token = tokenizer.next(RULE_7b_CONTEXT);
        Assert.assertEquals(TOK_WORD, token.getTokenType());
        token = tokenizer.next(RULE_7b_CONTEXT);
        Assert.assertEquals(TOK_END_OF_STREAM, token.getTokenType());
    }
View Full Code Here


        Assert.assertEquals(TOK_END_OF_STREAM, token.getTokenType());
    }

    @Test
    public void testRule8() throws ShellSyntaxException {
        BjorneTokenizer tokenizer =
                new BjorneTokenizer(
                        "if then else elif fi for done while until case { } ! do in esac a a_b a= a=b 1a=b =c");
        BjorneToken token = tokenizer.next(RULE_8_CONTEXT);
        Assert.assertEquals(TOK_IF, token.getTokenType());
        token = tokenizer.next(RULE_8_CONTEXT);
        Assert.assertEquals(TOK_THEN, token.getTokenType());
        token = tokenizer.next(RULE_8_CONTEXT);
        Assert.assertEquals(TOK_ELSE, token.getTokenType());
        token = tokenizer.next(RULE_8_CONTEXT);
        Assert.assertEquals(TOK_ELIF, token.getTokenType());
        token = tokenizer.next(RULE_8_CONTEXT);
        Assert.assertEquals(TOK_FI, token.getTokenType());
        token = tokenizer.next(RULE_8_CONTEXT);
        Assert.assertEquals(TOK_FOR, token.getTokenType());
        token = tokenizer.next(RULE_8_CONTEXT);
        Assert.assertEquals(TOK_DONE, token.getTokenType());
        token = tokenizer.next(RULE_8_CONTEXT);
        Assert.assertEquals(TOK_WHILE, token.getTokenType());
        token = tokenizer.next(RULE_8_CONTEXT);
        Assert.assertEquals(TOK_UNTIL, token.getTokenType());
        token = tokenizer.next(RULE_8_CONTEXT);
        Assert.assertEquals(TOK_CASE, token.getTokenType());
        token = tokenizer.next(RULE_8_CONTEXT);
        Assert.assertEquals(TOK_LBRACE, token.getTokenType());
        token = tokenizer.next(RULE_8_CONTEXT);
        Assert.assertEquals(TOK_RBRACE, token.getTokenType());
        token = tokenizer.next(RULE_8_CONTEXT);
        Assert.assertEquals(TOK_BANG, token.getTokenType());
        token = tokenizer.next(RULE_8_CONTEXT);
        Assert.assertEquals(TOK_DO, token.getTokenType());
        token = tokenizer.next(RULE_8_CONTEXT);
        Assert.assertEquals(TOK_NAME, token.getTokenType()); // yes: in -> NAME
        token = tokenizer.next(RULE_8_CONTEXT);
        Assert.assertEquals(TOK_ESAC, token.getTokenType());
        token = tokenizer.next(RULE_8_CONTEXT);
        Assert.assertEquals(TOK_NAME, token.getTokenType());
        token = tokenizer.next(RULE_8_CONTEXT);
        Assert.assertEquals(TOK_NAME, token.getTokenType());
        token = tokenizer.next(RULE_8_CONTEXT);
        Assert.assertEquals(TOK_ASSIGNMENT, token.getTokenType());
        token = tokenizer.next(RULE_8_CONTEXT);
        Assert.assertEquals(TOK_ASSIGNMENT, token.getTokenType());
        token = tokenizer.next(RULE_8_CONTEXT);
        Assert.assertEquals(TOK_WORD, token.getTokenType());
        token = tokenizer.next(RULE_8_CONTEXT);
        Assert.assertEquals(TOK_WORD, token.getTokenType());
        token = tokenizer.next(RULE_8_CONTEXT);
        Assert.assertEquals(TOK_END_OF_STREAM, token.getTokenType());
    }
View Full Code Here

        Assert.assertEquals(TOK_END_OF_STREAM, token.getTokenType());
    }

    @Test
    public void testRegress() throws ShellSyntaxException {
        BjorneTokenizer tokenizer = new BjorneTokenizer("ls -l");
        BjorneToken token = tokenizer.peek(RULE_7a_CONTEXT);
        Assert.assertEquals(TOK_WORD, token.getTokenType());
        Assert.assertEquals("ls", token.getText());
        token = tokenizer.next();
        Assert.assertEquals(TOK_WORD, token.getTokenType());
        Assert.assertEquals("ls", token.getText());
        token = tokenizer.peek();
        Assert.assertEquals(TOK_WORD, token.getTokenType());
        Assert.assertEquals("-l", token.getText());
        token = tokenizer.next();
        Assert.assertEquals(TOK_WORD, token.getTokenType());
        Assert.assertEquals("-l", token.getText());
        token = tokenizer.peek();
        Assert.assertEquals(TOK_END_OF_STREAM, token.getTokenType());
        token = tokenizer.next();
        Assert.assertEquals(TOK_END_OF_STREAM, token.getTokenType());
    }
View Full Code Here

    private static final boolean DEBUG = false;

    @Test
    public void testParser() throws ShellException {
        new BjorneParser(new BjorneTokenizer(""));
    }
View Full Code Here

                + "SimpleCommand{nodeType=1,words=[WORD{echo},WORD{false}]}}",
                doTest("if true ; then echo yes ; else echo false ; fi"));
    }

    private String doTest(String input) throws ShellException {
        BjorneParser p = new BjorneParser(new BjorneTokenizer(new StringReader(input), DEBUG));
        String res = p.parse().toString();
        if (DEBUG) {
            System.err.println(res);
        }
        return res;
View Full Code Here

TOP

Related Classes of org.jnode.shell.bjorne.BjorneTokenizer

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.