Search in sources :

Example 11 with StatementExpression

use of com.yahoo.vespa.indexinglanguage.expressions.StatementExpression in project vespa by vespa-engine.

the class ScriptParserTestCase method requireThatScriptParserBacksUpStream.

@Test
public void requireThatScriptParserBacksUpStream() throws ParseException {
    ScriptParserContext config = newContext("{ input foo }{ input bar }");
    assertEquals(new ScriptExpression(new StatementExpression(new InputExpression("foo"))), ScriptParser.parseScript(config));
    assertEquals(new ScriptExpression(new StatementExpression(new InputExpression("bar"))), ScriptParser.parseScript(config));
}
Also used : StatementExpression(com.yahoo.vespa.indexinglanguage.expressions.StatementExpression) InputExpression(com.yahoo.vespa.indexinglanguage.expressions.InputExpression) ScriptExpression(com.yahoo.vespa.indexinglanguage.expressions.ScriptExpression) Test(org.junit.Test)

Example 12 with StatementExpression

use of com.yahoo.vespa.indexinglanguage.expressions.StatementExpression in project vespa by vespa-engine.

the class ScriptParserTestCase method requireThatStatementParserCanBeInvoked.

@Test
public void requireThatStatementParserCanBeInvoked() throws ParseException {
    try {
        ScriptParser.parseStatement(newContext("foo"));
    } catch (ParseException e) {
        assertException(e, "Encountered \" <IDENTIFIER> \"foo \"\" at line 1, column 1.");
    }
    assertEquals(new StatementExpression(new InputExpression("foo")), ScriptParser.parseStatement(newContext("input foo")));
    assertEquals(new StatementExpression(new InputExpression("foo"), new EchoExpression()), ScriptParser.parseStatement(newContext("input foo | echo")));
    assertEquals(new StatementExpression(new ScriptExpression(new StatementExpression(new InputExpression("foo")), new StatementExpression(new EchoExpression()))), ScriptParser.parseStatement(newContext("{ input foo; echo }")));
}
Also used : StatementExpression(com.yahoo.vespa.indexinglanguage.expressions.StatementExpression) EchoExpression(com.yahoo.vespa.indexinglanguage.expressions.EchoExpression) ParseException(com.yahoo.vespa.indexinglanguage.parser.ParseException) InputExpression(com.yahoo.vespa.indexinglanguage.expressions.InputExpression) ScriptExpression(com.yahoo.vespa.indexinglanguage.expressions.ScriptExpression) Test(org.junit.Test)

Aggregations

StatementExpression (com.yahoo.vespa.indexinglanguage.expressions.StatementExpression)12 InputExpression (com.yahoo.vespa.indexinglanguage.expressions.InputExpression)10 ScriptExpression (com.yahoo.vespa.indexinglanguage.expressions.ScriptExpression)10 Test (org.junit.Test)10 AttributeExpression (com.yahoo.vespa.indexinglanguage.expressions.AttributeExpression)6 EchoExpression (com.yahoo.vespa.indexinglanguage.expressions.EchoExpression)6 ArithmeticExpression (com.yahoo.vespa.indexinglanguage.expressions.ArithmeticExpression)5 CatExpression (com.yahoo.vespa.indexinglanguage.expressions.CatExpression)5 ForEachExpression (com.yahoo.vespa.indexinglanguage.expressions.ForEachExpression)5 GuardExpression (com.yahoo.vespa.indexinglanguage.expressions.GuardExpression)5 IfThenExpression (com.yahoo.vespa.indexinglanguage.expressions.IfThenExpression)5 IndexExpression (com.yahoo.vespa.indexinglanguage.expressions.IndexExpression)5 ParenthesisExpression (com.yahoo.vespa.indexinglanguage.expressions.ParenthesisExpression)5 SelectInputExpression (com.yahoo.vespa.indexinglanguage.expressions.SelectInputExpression)5 SwitchExpression (com.yahoo.vespa.indexinglanguage.expressions.SwitchExpression)5 Base64DecodeExpression (com.yahoo.vespa.indexinglanguage.expressions.Base64DecodeExpression)4 Base64EncodeExpression (com.yahoo.vespa.indexinglanguage.expressions.Base64EncodeExpression)4 ClearStateExpression (com.yahoo.vespa.indexinglanguage.expressions.ClearStateExpression)4 GetFieldExpression (com.yahoo.vespa.indexinglanguage.expressions.GetFieldExpression)4 GetVarExpression (com.yahoo.vespa.indexinglanguage.expressions.GetVarExpression)4