public UnaryExpression(JsUnaryOperator op, JsToken target) { Op = op; Target = target; }
public BinaryExpression(JsToken left, JsBooleanOperand operand, JsToken right) { Left = left; Operand = operand; Right = right; }
public static JsExpression CreateJsExpression(JsToken lhs, JsBinaryOperator op, JsToken rhs) { if (op is JsAnd opAnd) { return(new JsLogicalExpression(lhs, opAnd, rhs)); } if (op is JsOr opOr) { return(new JsLogicalExpression(lhs, opOr, rhs)); } return(new JsBinaryExpression(lhs, op, rhs)); }
private static StringSegment ParseJsConditionalExpression(this StringSegment literal, JsToken test, out JsConditionalExpression expression) { literal = literal.Advance(1); literal = literal.ParseJsExpression(out var consequent); literal = literal.AdvancePastWhitespace(); if (!literal.FirstCharEquals(':')) { throw new SyntaxErrorException($"Expected Conditional ':' but was {literal.DebugFirstChar()}"); } literal = literal.Advance(1); literal = literal.ParseJsExpression(out var alternate); expression = new JsConditionalExpression(test, consequent, alternate); return(literal); }
public static StringSegment ParseJsExpression(this StringSegment literal, out JsToken token) => literal.ParseJsExpression(out token, filterExpression: false);
public static StringSegment ParseJsExpression(this string literal, out JsToken token) => literal.ToStringSegment().ParseJsExpression(out token);
public JsUnaryExpression(JsUnaryOperator @operator, JsToken argument) { Operator = @operator; Argument = argument; }