Esempio n. 1
0
        // SequenceLiteral := '[' ExpressionList? ']'
        private Expression DoParseSequenceLiteral(int line, List<string> locals)
        {
            Expression[] elements = new Expression[0];

            if (!m_scanner.Token.IsPunct("]"))
            {
                elements = DoParseExpressionList(locals);
            }

            DoParsePunct("]", "to end the sequence literal");

            return new SequenceLiteral(line, elements);
        }
Esempio n. 2
0
        // WhenExpression := OrExpression 'when' OrExpression 'else' OrExpression
        private Expression DoParseWhenExpression(List<string> locals, Expression trueValue, int line)
        {
            Expression predicate = DoParseOrExpression(locals);
            DoParseKeyword("else", "for the when expression");
            Expression falseValue = DoParseOrExpression(locals);

            return new When(line, predicate, trueValue, falseValue);
        }
Esempio n. 3
0
        // ActualArgs := '(' ExpressionList? ')'
        private Expression[] DoParseActualArgs(List<string> locals, string method)
        {
            Expression[] args;

            DoParsePunct("(", string.Format("to open the {0} method argument list", method));

            if (!m_scanner.Token.IsPunct(")"))
                args = DoParseExpressionList(locals);
            else
                args = new Expression[0];

            DoParsePunct(")", string.Format("to close the {0} method argument list", method));

            return args;
        }
Esempio n. 4
0
        // MethodCall := Identifier ActualArgs?
        private Expression DoParseMethodCall(int line, List<string> locals, Expression target)
        {
            Expression result;

            string name = DoParseIdentifier("for a method or property name");

            if (m_scanner.Token.IsPunct("("))
            {
                Expression[] args = DoParseActualArgs(locals, name);
                result = new InvokeMethod(line, target, name, args);
            }
            else
            {
                result = new InvokeMethod(line, target, "get_" + name, new Expression[0]);
            }

            return result;
        }
Esempio n. 5
0
        public Return(int line, Expression expr)
            : base(line)
        {
            Contract.Requires(expr != null, "expr is null");

            m_expr = expr;
        }
Esempio n. 6
0
        public MethodCall(int line, Expression invoke)
            : base(line)
        {
            Contract.Requires(invoke != null, "invoke is null");

            m_invoke = invoke;
        }
Esempio n. 7
0
        public Let(int line, string[] locals, Expression[] values, Statement[] block)
            : base(line)
        {
            Contract.Requires(locals != null, "locals is null");
            Contract.Requires(values != null, "value is null");
            Contract.Requires(locals.Length == values.Length, "lengths don't match");
            Contract.Requires(block != null, "block is null");

            m_locals = locals;
            m_values = values;
            m_block = block;
        }
Esempio n. 8
0
        public For(int line, string local, Expression elements, Expression filter, Statement[] block)
            : base(line)
        {
            Contract.Requires(!string.IsNullOrEmpty(local), "local is null or null");
            Contract.Requires(elements != null, "elements is null");
            Contract.Requires(block != null, "block is null");

            m_local = local;
            m_elements = elements;
            m_filter = filter;
            m_block = block;
        }
Esempio n. 9
0
        public Conditional(int line, Expression[] predicates, Statement[][] blocks)
            : base(line)
        {
            Contract.Requires(predicates != null, "predicates is null");
            Contract.Requires(blocks != null, "blocks is null");
            Contract.Requires(predicates.Length == blocks.Length, "lengths differ");

            m_predicates = predicates;
            m_blocks = blocks;
        }