Exemple #1
0
 public UnaryExpression(JsUnaryOperator op, JsToken target)
 {
     Op     = op;
     Target = target;
 }
Exemple #2
0
 public BinaryExpression(JsToken left, JsBooleanOperand operand, JsToken right)
 {
     Left    = left;
     Operand = operand;
     Right   = right;
 }
Exemple #3
0
        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));
        }
Exemple #4
0
        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);
        }
Exemple #5
0
 public static StringSegment ParseJsExpression(this StringSegment literal, out JsToken token) =>
 literal.ParseJsExpression(out token, filterExpression: false);
Exemple #6
0
 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;
 }