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

Examples of com.github.sommeri.less4j.core.parser.ANTLRParser.ParseResult


  @Test
  public void stylesheet() throws RecognitionException {
    String crashingSelector =   "p:not([class**=\"lead\"]) {\n  color: black;\n}";
    ANTLRParser compiler = new ANTLRParser();
    ParseResult result = compiler.parseStyleSheet(crashingSelector, null);

    //the -3 is correct, even if it seems like huge hack. It sort of is.
    //RBRACE }; LBRACE {; RBRACKET ] and LBRACKET [ are (correctly thrown away)
    //and one dummy node EMPTY_COMBINATOR is added during the translation.
    //therefore there are -3 dummy nodes
    //this way of testing malformed trees is bad anyway,this needs to be changed
    //for something more readable and stable. (These tests are broken with each tree change)
    assertNoTokenMissing(crashingSelector, result.getTree(), -4);
  }
View Full Code Here


        "li:nth-child(-n+2) {\n" +
        "  color: white;\n" +
        "}";
   
    ANTLRParser compiler = new ANTLRParser();
    ParseResult result = compiler.parseStyleSheet(combined_stylesheet, null);
    assertValid(result);
  }
View Full Code Here

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);
  }
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);
  }
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);
  }
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);
  }
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);
  }
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);
  }
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

Related Classes of com.github.sommeri.less4j.core.parser.ANTLRParser.ParseResult

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.