public static StringSegment ParseJsExpression(this StringSegment literal, out JsToken token, bool filterExpression) { var peekLiteral = literal.ParseJsToken(out var token1, filterExpression: filterExpression); peekLiteral = peekLiteral.AdvancePastWhitespace(); if (peekLiteral.IsNullOrEmpty()) { token = token1; return(peekLiteral); } var peekChar = peekLiteral.GetChar(0); if (JsTokenUtils.ExpressionTerminator.Contains(peekChar)) { token = token1; return(peekLiteral); } if (token1 is JsSubtraction) { token1 = JsMinus.Operator; } if (token1 is JsAddition) { token1 = JsPlus.Operator; } if (token1 is JsUnaryOperator u) { literal = peekLiteral.ParseJsToken(out var token2, filterExpression: filterExpression); token = new JsUnaryExpression(u, token2); return(literal); } peekLiteral = peekLiteral.AdvancePastWhitespace(); if (!peekLiteral.IsNullOrEmpty()) { if (filterExpression && peekLiteral.Length > 2) { if ((peekLiteral.GetChar(0) == '|' && peekLiteral.GetChar(1) != '|') || (peekLiteral.GetChar(0) == '}' && peekLiteral.GetChar(1) == '}')) { token = token1; return(peekLiteral); } } } peekLiteral = peekLiteral.ParseJsToken(out JsToken op, filterExpression: filterExpression); if (op is JsAssignment) { op = JsEquals.Operator; } if (op is JsBinaryOperator) { literal = literal.ParseBinaryExpression(out var expr, filterExpression); token = expr; return(literal); } token = token1; return(peekLiteral); }
protected bool Equals(JsUnaryExpression other) => Equals(Operator, other.Operator) && Equals(Argument, other.Argument);