static bool parseMulDivExpression(MemoryStack* stack, LexerCarriage* carriage, Array<SyntaxError>* errors, ASTNode* result) { ASTNode left; if (parseValueExpression(stack, carriage, errors, &left)) return parseMulDivExpression(stack, carriage, errors, left, result); else return false; }
PassRefPtrWillBeRawPtr<CSSCalcExpressionNode> parseCalc(CSSParserTokenRange tokens) { Value result; tokens.consumeWhitespace(); bool ok = parseValueExpression(tokens, 0, &result); if (!ok || !tokens.atEnd()) return nullptr; return result.value; }
PassRefPtr<CSSCalcExpressionNode> parseCalc(CSSParserValueList* tokens) { unsigned index = 0; Value result; bool ok = parseValueExpression(tokens, 0, &index, &result); ASSERT(index <= tokens->size()); if (!ok || index != tokens->size()) return 0; return result.value; }
static bool parseMulDivExpression(MemoryStack* stack, LexerCarriage* carriage, Array<SyntaxError>* errors, ASTNode left, ASTNode* result) { if (carriage->topToken.type == TOK_MULTIPLY) { parseNextToken(carriage); ASTNode right; if (parseValueExpression(stack, carriage, errors, &right)) { makeFunctionCallNode(result, stack, "opMul", left, right); parseMulDivExpression(stack, carriage, errors, *result, result); return true; } else pushBack(errors, SyntaxError{ SET_EXPRESSION_EXPECTED, carriage->currentLineNumber }); } else if (carriage->topToken.type == TOK_DIVIDE) { parseNextToken(carriage); ASTNode right; if (parseValueExpression(stack, carriage, errors, &right)) { makeFunctionCallNode(result, stack, "opDiv", left, right); parseMulDivExpression(stack, carriage, errors, *result, result); return true; } else pushBack(errors, SyntaxError{ SET_EXPRESSION_EXPECTED, carriage->currentLineNumber }); } else { *result = left; return true; } return false; }
bool parseValueTerm(CSSParserTokenRange& tokens, int depth, Value* result) { if (checkDepthAndIndex(&depth, tokens) != OK) return false; if (tokens.peek().type() == LeftParenthesisToken) { CSSParserTokenRange innerRange = tokens.consumeBlock(); tokens.consumeWhitespace(); innerRange.consumeWhitespace(); return parseValueExpression(innerRange, depth, result); } return parseValue(tokens, result); }
bool parseValueTerm(CSSParserValueList* tokens, int depth, unsigned* index, Value* result) { if (checkDepthAndIndex(&depth, *index, tokens) != OK) return false; if (operatorValue(tokens, *index) == '(') { unsigned currentIndex = *index + 1; if (!parseValueExpression(tokens, depth, ¤tIndex, result)) return false; if (operatorValue(tokens, currentIndex) != ')') return false; *index = currentIndex + 1; return true; } return parseValue(tokens, index, result); }