Package com.github.sommeri.less4j.core.parser

Examples of com.github.sommeri.less4j.core.parser.ANTLRParser.parseExpression()


public class ExpressionGrammarTest {

  @Test
  public void sequenceNumbersLong() {
    ANTLRParser compiler = new ANTLRParser();
    ParseResult result = compiler.parseExpression("12-34 56+7 8*90 ", null);
    assertValidExpression(result);
    assertChilds(result.getTree(), LessLexer.NUMBER, LessLexer.MINUS, LessLexer.NUMBER, LessLexer.EMPTY_SEPARATOR, LessLexer.NUMBER, LessLexer.PLUS, LessLexer.NUMBER, LessLexer.EMPTY_SEPARATOR, LessLexer.NUMBER, LessLexer.STAR, LessLexer.NUMBER);
  }

  @Test
View Full Code Here


  }

  @Test
  public void sequenceNumbersLongSpaces() {
    ANTLRParser compiler = new ANTLRParser();
    ParseResult result = compiler.parseExpression("12 - 34 56 + 7 8 * 90 ", null);
    assertValidExpression(result);
    assertChilds(result.getTree(), LessLexer.NUMBER, LessLexer.MINUS, LessLexer.NUMBER, LessLexer.EMPTY_SEPARATOR, LessLexer.NUMBER, LessLexer.PLUS, LessLexer.NUMBER, LessLexer.EMPTY_SEPARATOR, LessLexer.NUMBER, LessLexer.STAR, LessLexer.NUMBER);
  }

  @Test
View Full Code Here

  }

  @Test
  public void sequencePixels() {
    ANTLRParser compiler = new ANTLRParser();
    ParseResult result = compiler.parseExpression("12px 13px", null);
    assertValidExpression(result);
    assertChilds(result.getTree(), LessLexer.LENGTH, LessLexer.EMPTY_SEPARATOR, LessLexer.LENGTH);
  }

  @Test
View Full Code Here

  }

  @Test
  public void plusPixels() {
    ANTLRParser compiler = new ANTLRParser();
    ParseResult result = compiler.parseExpression("12px + 13px", null);
    assertValidExpression(result);
    assertChilds(result.getTree(), LessLexer.LENGTH, LessLexer.PLUS, LessLexer.LENGTH);
  }

  @Test
View Full Code Here

  }

  @Test
  public void plusPixelsShort() {
    ANTLRParser compiler = new ANTLRParser();
    ParseResult result = compiler.parseExpression("12px+13px", null);
    assertValidExpression(result);
    assertChilds(result.getTree(), LessLexer.LENGTH, LessLexer.PLUS, LessLexer.LENGTH);
  }

  @Test
View Full Code Here

  }

  @Test
  public void sequenceNumbers() {
    ANTLRParser compiler = new ANTLRParser();
    ParseResult result = compiler.parseExpression("1.2 13 ", null);
    assertValidExpression(result);
    assertChilds(result.getTree(), LessLexer.NUMBER, LessLexer.EMPTY_SEPARATOR, LessLexer.NUMBER);
  }

  @Test
View Full Code Here

  }

  @Test
  public void floating() {
    ANTLRParser compiler = new ANTLRParser();
    ParseResult result = compiler.parseExpression("1.2 ", null);

    assertValidExpression(result);
    assertEquals(1, result.getTree().getChildren().size());
    assertEquals(LessLexer.NUMBER, result.getTree().getChild(0).getType());
  }
View Full Code Here

  }

  @Test
  public void integer() {
    ANTLRParser compiler = new ANTLRParser();
    ParseResult result = compiler.parseExpression("12 ", null);

    assertValidExpression(result);
    assertEquals(1, result.getTree().getChildren().size());
    assertEquals(LessLexer.NUMBER, result.getTree().getChild(0).getType());
  }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.