public LuaStatement Parse(INextAwareEnumerator <Token> reader, IParserContext context)
        {
            var variables = ReadDeclarations(reader);

            foreach (var variable in variables)
            {
                context.CurrentScope.AddVariable(variable);
            }
            reader.VerifyExpectedTokenAndMoveNext(LuaToken.EqualsSign);
            var assignedExpressionParser = new ExpressionListParser();
            var expressions = assignedExpressionParser.Parse(reader, context);

            return(new Assignment(variables, expressions, _local));
        }
Esempio n. 2
0
        public LuaStatement Parse(INextAwareEnumerator <Token> reader, IParserContext context)
        {
            reader.VerifyExpectedTokenAndMoveNext(Keywords.For);
            var scope = context.AcquireScope();

            reader.VerifyIsIdentifier();
            var forVariableName = reader.GetAndMoveNext();

            reader.VerifyExpectedTokenAndMoveNext(LuaToken.EqualsSign);
            var conditionsParser = new ExpressionListParser();
            var conditions       = conditionsParser.Parse(reader, context).ToList();

            reader.VerifyExpectedTokenAndMoveNext(Keywords.Do);

            var statementsParser = new StatementBlockParser(Keywords.End);
            var bodyBlock        = statementsParser.ParseBlock(reader, context);

            context.ReleaseScope(scope);
            return(new ForStatement(conditions, bodyBlock));
        }