Package org.jnode.shell.bjorne

Examples of org.jnode.shell.bjorne.BjorneToken


    @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


    }

    @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

    }

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

    }

    @Test
    public void testExpand4() throws ShellException {
        BjorneContext context = new TestBjorneContext();
        List<BjorneToken> expansion = context.expandAndSplit(new BjorneToken("hi there"));
        checkExpansion(expansion, new String[] {"hi", "there"});
    }
View Full Code Here

    }

    @Test
    public void testExpand5() throws ShellException {
        BjorneContext context = new TestBjorneContext();
        List<BjorneToken> expansion = context.expandAndSplit(new BjorneToken("'hi there '"));
        checkExpansion(expansion, new String[] {"hi there "});
    }
View Full Code Here

    }

    @Test
    public void testExpand6() throws ShellException {
        BjorneContext context = new TestBjorneContext();
        List<BjorneToken> expansion = context.expandAndSplit(new BjorneToken("\"hi there \" "));
        checkExpansion(expansion, new String[] {"hi there "});
    }
View Full Code Here

    }

    @Test
    public void testExpand7() throws ShellException {
        BjorneContext context = new TestBjorneContext();
        List<BjorneToken> expansion = context.expandAndSplit(new BjorneToken("hi\\ there"));
        checkExpansion(expansion, new String[] {"hi there"});
    }
View Full Code Here

    }

    @Test
    public void testExpand8() throws ShellException {
        BjorneContext context = new TestBjorneContext();
        List<BjorneToken> expansion = context.expandAndSplit(new BjorneToken("\\\"hi\\ there\\\""));
        checkExpansion(expansion, new String[] {"\"hi there\""});
    }
View Full Code Here

    }

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

    @Test
    public void testExpand10() throws ShellException {
        TestBjorneContext context = new TestBjorneContext();
        context.setVariable("A", "A");
        List<BjorneToken> expansion = context.expandAndSplit(new BjorneToken("$A"));
        checkExpansion(expansion, new String[] {"A"});
    }
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.