Package org.jnode.shell.bjorne

Examples of org.jnode.shell.bjorne.BjorneTokenizer


public class BjorneTokenizerTest {

    @Test
    public void testBjorneTokenizer() throws ShellSyntaxException {
        new BjorneTokenizer("hello");
    }
View Full Code Here


        new BjorneTokenizer("hello");
    }

    @Test
    public void testEmpty() throws ShellSyntaxException {
        BjorneTokenizer tokenizer = new BjorneTokenizer("");
        BjorneToken token = tokenizer.peek();
        Assert.assertEquals(TOK_END_OF_STREAM, token.getTokenType());
        token = tokenizer.peek(RULE_1_CONTEXT);
        Assert.assertEquals(TOK_END_OF_STREAM, token.getTokenType());
        token = tokenizer.next();
        Assert.assertEquals(TOK_END_OF_STREAM, token.getTokenType());
        token = tokenizer.next(RULE_1_CONTEXT);
        Assert.assertEquals(TOK_END_OF_STREAM, token.getTokenType());
    }
View Full Code Here

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

    @Test
    public void testNewline() throws ShellSyntaxException {
        BjorneTokenizer tokenizer = new BjorneTokenizer("\n");
        BjorneToken token = tokenizer.next();
        Assert.assertEquals(TOK_END_OF_LINE, token.getTokenType());
        token = tokenizer.next();
        Assert.assertEquals(TOK_END_OF_STREAM, token.getTokenType());
    }
View Full Code Here

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

    @Test
    public void testBlanksAndNewlines() throws ShellSyntaxException {
        BjorneTokenizer tokenizer = new BjorneTokenizer("  \n\t\n  ");
        BjorneToken token = tokenizer.next();
        Assert.assertEquals(TOK_END_OF_LINE, token.getTokenType());
        token = tokenizer.next();
        Assert.assertEquals(TOK_END_OF_LINE, token.getTokenType());
        token = tokenizer.next();
        Assert.assertEquals(TOK_END_OF_STREAM, token.getTokenType());
    }
View Full Code Here

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

    @Test
    public void testComments() throws ShellSyntaxException {
        BjorneTokenizer tokenizer = new BjorneTokenizer("# comment\n  #comment 2\n # comment # 3");
        BjorneToken token = tokenizer.next();
        Assert.assertEquals(TOK_END_OF_LINE, token.getTokenType());
        token = tokenizer.next();
        Assert.assertEquals(TOK_END_OF_LINE, token.getTokenType());
        token = tokenizer.next();
        Assert.assertEquals(TOK_END_OF_STREAM, token.getTokenType());
    }
View Full Code Here

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

    @Test
    public void testContinuation() throws ShellSyntaxException {
        BjorneTokenizer tokenizer = new BjorneTokenizer("hello\\\nthere");
        BjorneToken token = tokenizer.next();
        Assert.assertEquals(TOK_WORD, token.getTokenType());
        Assert.assertEquals("hellothere", token.getText());
        token = tokenizer.next();
        Assert.assertEquals(TOK_END_OF_STREAM, token.getTokenType());
    }
View Full Code Here

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

    @Test
    public void testBackslashAtEnd() throws ShellSyntaxException {
        BjorneTokenizer tokenizer = new BjorneTokenizer("hello\\");
        BjorneToken token = tokenizer.next();
        Assert.assertEquals(TOK_WORD, token.getTokenType());
        Assert.assertEquals("hello", token.getText());
        token = tokenizer.next();
        Assert.assertEquals(TOK_END_OF_STREAM, token.getTokenType());
    }
View Full Code Here

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

    @Test
    public void testSymbols() throws ShellSyntaxException {
        BjorneTokenizer tokenizer = new BjorneTokenizer("; | & < > ( )");
        BjorneToken token = tokenizer.next();
        Assert.assertEquals(TOK_SEMI, token.getTokenType());
        token = tokenizer.next();
        Assert.assertEquals(TOK_BAR, token.getTokenType());
        token = tokenizer.next();
        Assert.assertEquals(TOK_AMP, token.getTokenType());
        token = tokenizer.next();
        Assert.assertEquals(TOK_LESS, token.getTokenType());
        token = tokenizer.next();
        Assert.assertEquals(TOK_GREAT, token.getTokenType());
        token = tokenizer.next();
        Assert.assertEquals(TOK_LPAREN, token.getTokenType());
        token = tokenizer.next();
        Assert.assertEquals(TOK_RPAREN, token.getTokenType());
        token = tokenizer.next();
        Assert.assertEquals(TOK_END_OF_STREAM, token.getTokenType());
    }
View Full Code Here

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

    @Test
    public void testSymbols2() throws ShellSyntaxException {
        BjorneTokenizer tokenizer = new BjorneTokenizer("; ;; | || & && < << > >>");
        BjorneToken token = tokenizer.next();
        Assert.assertEquals(TOK_SEMI, token.getTokenType());
        token = tokenizer.next();
        Assert.assertEquals(TOK_DSEMI, token.getTokenType());
        token = tokenizer.next();
        Assert.assertEquals(TOK_BAR, token.getTokenType());
        token = tokenizer.next();
        Assert.assertEquals(TOK_OR_IF, token.getTokenType());
        token = tokenizer.next();
        Assert.assertEquals(TOK_AMP, token.getTokenType());
        token = tokenizer.next();
        Assert.assertEquals(TOK_AND_IF, token.getTokenType());
        token = tokenizer.next();
        Assert.assertEquals(TOK_LESS, token.getTokenType());
        token = tokenizer.next();
        Assert.assertEquals(TOK_DLESS, token.getTokenType());
        token = tokenizer.next();
        Assert.assertEquals(TOK_GREAT, token.getTokenType());
        token = tokenizer.next();
        Assert.assertEquals(TOK_DGREAT, token.getTokenType());
        token = tokenizer.next();
        Assert.assertEquals(TOK_END_OF_STREAM, token.getTokenType());
    }
View Full Code Here

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

    @Test
    public void testSymbols3() throws ShellSyntaxException {
        BjorneTokenizer tokenizer = new BjorneTokenizer(";;;|||&&&<<<>>>");
        BjorneToken token = tokenizer.next();
        Assert.assertEquals(TOK_DSEMI, token.getTokenType());
        token = tokenizer.next();
        Assert.assertEquals(TOK_SEMI, token.getTokenType());
        token = tokenizer.next();
        Assert.assertEquals(TOK_OR_IF, token.getTokenType());
        token = tokenizer.next();
        Assert.assertEquals(TOK_BAR, token.getTokenType());
        token = tokenizer.next();
        Assert.assertEquals(TOK_AND_IF, token.getTokenType());
        token = tokenizer.next();
        Assert.assertEquals(TOK_AMP, token.getTokenType());
        token = tokenizer.next();
        Assert.assertEquals(TOK_DLESS, token.getTokenType());
        token = tokenizer.next();
        Assert.assertEquals(TOK_LESSGREAT, token.getTokenType());
        token = tokenizer.next();
        Assert.assertEquals(TOK_DGREAT, token.getTokenType());
        token = tokenizer.next();
        Assert.assertEquals(TOK_END_OF_STREAM, token.getTokenType());
    }
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.