Package org.jnode.shell.bjorne

Examples of org.jnode.shell.bjorne.BjorneToken


    }

    @Test
    public void testExpand21() throws ShellException {
        TestBjorneContext context = new TestBjorneContext();
        List<BjorneToken> expansion = context.expandAndSplit(new BjorneToken("`Hello`"));
        checkExpansion(expansion, new String[] {"-hello-"});
    }
View Full Code Here


    }

    @Test
    public void testExpand22() throws ShellException {
        TestBjorneContext context = new TestBjorneContext();
        List<BjorneToken> expansion = context.expandAndSplit(new BjorneToken("$(Hello)"));
        checkExpansion(expansion, new String[] {"-hello-"});
    }
View Full Code Here

    }

    @Test
    public void testSymbols4() throws ShellSyntaxException {
        BjorneTokenizer tokenizer = new BjorneTokenizer("< << <<- <& <> > >> >| >&");
        BjorneToken token = tokenizer.next();
        Assert.assertEquals(TOK_LESS, token.getTokenType());
        token = tokenizer.next();
        Assert.assertEquals(TOK_DLESS, token.getTokenType());
        token = tokenizer.next();
        Assert.assertEquals(TOK_DLESSDASH, token.getTokenType());
        token = tokenizer.next();
        Assert.assertEquals(TOK_LESSAND, token.getTokenType());
        token = tokenizer.next();
        Assert.assertEquals(TOK_LESSGREAT, 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_CLOBBER, token.getTokenType());
        token = tokenizer.next();
        Assert.assertEquals(TOK_GREATAND, token.getTokenType());
        token = tokenizer.next();
        Assert.assertEquals(TOK_END_OF_STREAM, token.getTokenType());
    }
View Full Code Here

    }

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

    }

    @Test
    public void testWords2() throws ShellSyntaxException {
        BjorneTokenizer tokenizer = new BjorneTokenizer("hello\\ there\\\n friend");
        BjorneToken token = tokenizer.next();
        Assert.assertEquals(TOK_WORD, token.getTokenType());
        Assert.assertEquals("hello\\ there", token.getText());
        token = tokenizer.next();
        Assert.assertEquals(TOK_WORD, token.getTokenType());
        Assert.assertEquals("friend", token.getText());
        token = tokenizer.next();
        Assert.assertEquals(TOK_END_OF_STREAM, token.getTokenType());

        tokenizer = new BjorneTokenizer("hello\\ there\\\n\\ friend");
        token = tokenizer.next();
        Assert.assertEquals(TOK_WORD, token.getTokenType());
        Assert.assertEquals("hello\\ there\\ friend", token.getText());
        token = tokenizer.next();
        Assert.assertEquals(TOK_END_OF_STREAM, token.getTokenType());

        tokenizer = new BjorneTokenizer("hello\\\nthere\\\n friend");
        token = tokenizer.next();
        Assert.assertEquals(TOK_WORD, token.getTokenType());
        Assert.assertEquals("hellothere", token.getText());
        token = tokenizer.next();
        Assert.assertEquals(TOK_WORD, token.getTokenType());
        Assert.assertEquals("friend", token.getText());
        token = tokenizer.next();
        Assert.assertEquals(TOK_END_OF_STREAM, token.getTokenType());
    }
View Full Code Here

    }

    @Test
    public void testWords3() throws ShellSyntaxException {
        BjorneTokenizer tokenizer = new BjorneTokenizer("'1 2' \"3 4\" `5 6`");
        BjorneToken token = tokenizer.next();
        Assert.assertEquals(TOK_WORD, token.getTokenType());
        Assert.assertEquals("'1 2'", token.getText());
        token = tokenizer.next();
        Assert.assertEquals(TOK_WORD, token.getTokenType());
        Assert.assertEquals("\"3 4\"", token.getText());
        token = tokenizer.next();
        Assert.assertEquals(TOK_WORD, token.getTokenType());
        Assert.assertEquals("`5 6`", token.getText());
        token = tokenizer.next();
        Assert.assertEquals(TOK_END_OF_STREAM, token.getTokenType());
    }
View Full Code Here

    }

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

    }

    @Test
    public void testWords5() throws ShellSyntaxException {
        BjorneTokenizer tokenizer = new BjorneTokenizer("1<2>3&4;5|6)7");
        BjorneToken token = tokenizer.next();
        Assert.assertEquals(TOK_IO_NUMBER, token.getTokenType());
        Assert.assertEquals("1", token.getText());
        token = tokenizer.next();
        Assert.assertEquals(TOK_LESS, token.getTokenType());
        token = tokenizer.next();
        Assert.assertEquals(TOK_IO_NUMBER, token.getTokenType());
        Assert.assertEquals("2", token.getText());
        token = tokenizer.next();
        Assert.assertEquals(TOK_GREAT, token.getTokenType());
        token = tokenizer.next();
        Assert.assertEquals(TOK_WORD, token.getTokenType());
        Assert.assertEquals("3", token.getText());
        token = tokenizer.next();
        Assert.assertEquals(TOK_AMP, token.getTokenType());
        token = tokenizer.next();
        Assert.assertEquals(TOK_WORD, token.getTokenType());
        Assert.assertEquals("4", token.getText());
        token = tokenizer.next();
        Assert.assertEquals(TOK_SEMI, token.getTokenType());
        token = tokenizer.next();
        Assert.assertEquals(TOK_WORD, token.getTokenType());
        Assert.assertEquals("5", token.getText());
        token = tokenizer.next();
        Assert.assertEquals(TOK_BAR, token.getTokenType());
        token = tokenizer.next();
        Assert.assertEquals(TOK_WORD, token.getTokenType());
        Assert.assertEquals("6", token.getText());
        token = tokenizer.next();
        Assert.assertEquals(TOK_RPAREN, token.getTokenType());
        token = tokenizer.next();
        Assert.assertEquals(TOK_WORD, token.getTokenType());
        Assert.assertEquals("7", token.getText());
        token = tokenizer.next();
        Assert.assertEquals(TOK_END_OF_STREAM, token.getTokenType());
    }
View Full Code Here

    @Test
    public void testRule1() throws ShellSyntaxException {
        BjorneTokenizer tokenizer =
                new BjorneTokenizer(
                        "if then else elif fi for done while until case { } ! do in esac");
        BjorneToken token = tokenizer.next(RULE_1_CONTEXT);
        Assert.assertEquals(TOK_IF, token.getTokenType());
        token = tokenizer.next(RULE_1_CONTEXT);
        Assert.assertEquals(TOK_THEN, token.getTokenType());
        token = tokenizer.next(RULE_1_CONTEXT);
        Assert.assertEquals(TOK_ELSE, token.getTokenType());
        token = tokenizer.next(RULE_1_CONTEXT);
        Assert.assertEquals(TOK_ELIF, token.getTokenType());
        token = tokenizer.next(RULE_1_CONTEXT);
        Assert.assertEquals(TOK_FI, token.getTokenType());
        token = tokenizer.next(RULE_1_CONTEXT);
        Assert.assertEquals(TOK_FOR, token.getTokenType());
        token = tokenizer.next(RULE_1_CONTEXT);
        Assert.assertEquals(TOK_DONE, token.getTokenType());
        token = tokenizer.next(RULE_1_CONTEXT);
        Assert.assertEquals(TOK_WHILE, token.getTokenType());
        token = tokenizer.next(RULE_1_CONTEXT);
        Assert.assertEquals(TOK_UNTIL, token.getTokenType());
        token = tokenizer.next(RULE_1_CONTEXT);
        Assert.assertEquals(TOK_CASE, token.getTokenType());
        token = tokenizer.next(RULE_1_CONTEXT);
        Assert.assertEquals(TOK_LBRACE, token.getTokenType());
        token = tokenizer.next(RULE_1_CONTEXT);
        Assert.assertEquals(TOK_RBRACE, token.getTokenType());
        token = tokenizer.next(RULE_1_CONTEXT);
        Assert.assertEquals(TOK_BANG, token.getTokenType());
        token = tokenizer.next(RULE_1_CONTEXT);
        Assert.assertEquals(TOK_DO, token.getTokenType());
        token = tokenizer.next(RULE_1_CONTEXT);
        Assert.assertEquals(TOK_WORD, token.getTokenType());
        token = tokenizer.next(RULE_1_CONTEXT);
        Assert.assertEquals(TOK_ESAC, token.getTokenType());
        token = tokenizer.next(RULE_1_CONTEXT);
        Assert.assertEquals(TOK_END_OF_STREAM, token.getTokenType());
    }
View Full Code Here

    }

    @Test
    public void testRule5() throws ShellSyntaxException {
        BjorneTokenizer tokenizer = new BjorneTokenizer("if a a1 9a a_b a,b AB A=b");
        BjorneToken token = tokenizer.next(RULE_5_CONTEXT);
        Assert.assertEquals(TOK_NAME, token.getTokenType());
        token = tokenizer.next(RULE_5_CONTEXT);
        Assert.assertEquals(TOK_NAME, token.getTokenType());
        token = tokenizer.next(RULE_5_CONTEXT);
        Assert.assertEquals(TOK_NAME, token.getTokenType());
        token = tokenizer.next(RULE_5_CONTEXT);
        Assert.assertEquals(TOK_WORD, token.getTokenType());
        token = tokenizer.next(RULE_5_CONTEXT);
        Assert.assertEquals(TOK_NAME, token.getTokenType());
        token = tokenizer.next(RULE_5_CONTEXT);
        Assert.assertEquals(TOK_WORD, token.getTokenType());
        token = tokenizer.next(RULE_5_CONTEXT);
        Assert.assertEquals(TOK_NAME, token.getTokenType());
        token = tokenizer.next(RULE_5_CONTEXT);
        Assert.assertEquals(TOK_WORD, token.getTokenType());
        token = tokenizer.next(RULE_5_CONTEXT);
        Assert.assertEquals(TOK_END_OF_STREAM, token.getTokenType());
    }
View Full Code Here

TOP

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

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.