Package com.github.sommeri.less4j.core.ast

Examples of com.github.sommeri.less4j.core.ast.Expression


    }
  }

  private void addParameter(ReusableStructure declaration, ASTCssNode parameter) {
    if (parameter.getType()==ASTCssNodeType.ARGUMENT_DECLARATION) {
      Expression value = ((ArgumentDeclaration) parameter).getValue();
      if (AstLogic.isDetachedRuleset(value))
        problemsHandler.warnDetachedRulesetAsMixinParamDefault(value);
    }
    declaration.addParameter(parameter);
  }
View Full Code Here


    declaration.addParameter(parameter);
  }

  private void addParameters(ReusableStructure declaration, Iterator<Expression> expressions) {
    while (expressions.hasNext()) {
      Expression next = expressions.next();
     
      if (next.getType()==ASTCssNodeType.VARIABLE) {
        addParameter(declaration, new ArgumentDeclaration((Variable)next, null));
      } else {
        addParameter(declaration, next);
      }
    }
View Full Code Here

  private Expression buildFromUnicodeRange(HiddenTokenAwareTree parent, HiddenTokenAwareTree first) {
    return new UnicodeRangeExpression(parent, first.getText());
  }

  private FunctionExpression buildFromSpecialFunction(HiddenTokenAwareTree token, String function, HiddenTokenAwareTree first) {
    Expression parameter = extractUrlParameter(token, function, normalizeNewLineSymbols(first.getText()));
    parameter = packIntoListExpression(parameter);
    return new FunctionExpression(token, function, parameter);
  }
View Full Code Here

      return new FunctionExpression(token, name, new EmptyExpression(token));
    }

    HiddenTokenAwareTree parameterNode = children.get(1);

    Expression parameter = (Expression) parentBuilder.switchOn(parameterNode);
    //FIXME: (API) this is a hack - if what come out is not comma separated list, add it to comma separated list. - once there is API changing version it will be better to store parameters list in the function
    if (!isListOfParameters(parameter)) {
      parameter = packIntoListExpression(parameter);
    }
    return new FunctionExpression(token, name, parameter);
View Full Code Here

    LinkedList<HiddenTokenAwareTree> children = new LinkedList<HiddenTokenAwareTree>(token.getChildren());
    if (children.size() == 0)
      throw new BugHappened(GRAMMAR_MISMATCH, token);

    if (children.size() == 1) {
      Expression head = (Expression) switchOn(children.get(0));
      // we have to switch to parent token, because we would loose it otherwise.
      // for example, comments before simple expressions would not be accessible
      // anymore
      head.setUnderlyingStructure(token);
      return head;
    }
   
    if (null!=toListExpressionOperator(children.get(1)))
      return createListExpression(token, children);
View Full Code Here

  }

  private Expression createListExpression(HiddenTokenAwareTree parent, LinkedList<HiddenTokenAwareTree> members) {
    Iterator<HiddenTokenAwareTree> iterator = members.iterator();
    // this must represent a term. Otherwise we are doomed anyway.
    Expression head = (Expression) switchOn(iterator.next());
    List<Expression> spaceSeparatedExpressions = new ArrayList<Expression>();
    spaceSeparatedExpressions.add(head);
    ListExpressionOperator space=null;
   
    List<Expression> commaSeparatedExpressions = new ArrayList<Expression>();
View Full Code Here

  private Expression maybeList(List<Expression> expressions, ListExpressionOperator operator) {
    if (expressions.isEmpty())
      return null;
   
    Expression first = expressions.get(0);
    if (expressions.size()==1) {
      return first;
    }
   
    return new ListExpression(first.getUnderlyingStructure(), expressions, operator);
  }
View Full Code Here

    return new ListExpression(first.getUnderlyingStructure(), expressions, operator);
  }

  private Expression createBinaryExpression(HiddenTokenAwareTree parent, LinkedList<HiddenTokenAwareTree> members) {
    // this must represent a term. Otherwise we are doomed anyway.
    Expression head = (Expression) switchOn(members.removeFirst());
    while (!members.isEmpty()) {
      BinaryExpressionOperator operator = createBinaryOperator(members.removeFirst());
      if (members.isEmpty())
        return new BinaryExpression(parent, head, operator, null);

      Expression next = (Expression) switchOn(members.removeFirst());
      head = new BinaryExpression(parent, head, operator, next);
    }
    return head;
  }
View Full Code Here

    }

    if (expressionToken.getType() == LessLexer.IMPORTANT_SYM)
      return new Declaration(token, name, null, true, mergeOperator);

    Expression expression = (Expression) switchOn(expressionToken);
    if (!iterator.hasNext())
      return new Declaration(token, name, expression, mergeOperator);

    HiddenTokenAwareTree importantToken = iterator.next();
    if (importantToken.getType() == LessLexer.IMPORTANT_SYM)
View Full Code Here

      validateGuardNegation(kid);
      isNegated = true;
      kid = iterator.next();
    }

    Expression condition = handleExpression(kid);
    if (iterator.hasNext()) {
      HiddenTokenAwareTree operatorToken = iterator.next();
      Expression followingExpression = handleExpression(iterator.next());
      condition = new ComparisonExpression(token, condition, toComparisonOperator(operatorToken), followingExpression);
    }

    return new GuardCondition(token, isNegated, condition);
  }
View Full Code Here

TOP

Related Classes of com.github.sommeri.less4j.core.ast.Expression

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.