Package com.google.template.soy.exprparse

Examples of com.google.template.soy.exprparse.ExpressionParser


  /**
   * Private helper to check the rewrite of one expression.
   */
  private void assertRewrite(String origSrc, String expectedRewrittenSrc) throws Exception {

    ExprNode expr = (new ExpressionParser(origSrc)).parseExpression();
    (new RewriteNullCoalescingOpInExprVisitor()).exec(expr);
    String rewrittenSrc = expr.toSourceString();
    assertEquals(expectedRewrittenSrc, rewrittenSrc);
  }
View Full Code Here


      }
      String name = matcher.group(1);
      String valueText = matcher.group(2).trim();

      try {
        ExprNode valueExpr = (new ExpressionParser(valueText)).parseExpression().getChild(0);

        // Handle negative numbers as a special case.
        // TODO: Consider changing parser to actually parse negative numbers as primitives.
        if (valueExpr instanceof NegativeOpNode) {
          ExprNode childExpr = ((NegativeOpNode) valueExpr).getChild(0);
View Full Code Here

public class SubstituteGlobalsVisitorTest extends TestCase {


  public void testSubstituteGlobals() throws Exception {

    ExprRootNode<?> expr = (new ExpressionParser("BOO + 'aaa' + foo.GOO")).parseExpression();
    PlusOpNode plus0 = (PlusOpNode) expr.getChild(0);
    PlusOpNode plus1 = (PlusOpNode) plus0.getChild(0);

    assertEquals("BOO", ((GlobalNode) plus1.getChild(0)).getName());
    assertEquals("foo.GOO", ((GlobalNode) plus0.getChild(1)).getName());
View Full Code Here

  }


  public void testAssertNoUnboundGlobals() throws Exception {

    ExprRootNode<?> expr = (new ExpressionParser("BOO + 'aaa' + foo.GOO")).parseExpression();

    Map<String, PrimitiveData> globals =
        ImmutableMap.<String, PrimitiveData>of(
            "BOO", StringData.forValue("boo"), "GOO", StringData.forValue("goo"),
            "foo.MOO", StringData.forValue("moo"));
View Full Code Here

TOP

Related Classes of com.google.template.soy.exprparse.ExpressionParser

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.