public override LuaStatement Parse(INextAwareEnumerator<Token> reader, IParserContext context)
 {
     var scope = context.AcquireScope();
     reader.VerifyExpectedToken(Keywords.Do);
     reader.MoveNext();
     var statements = new List<LuaStatement>();
     while (reader.Current.Value != Keywords.End)
         statements.Add(SyntaxParser.ReadStatement(reader, context));
     reader.VerifyExpectedTokenAndMoveNext(Keywords.End);
     context.ReleaseScope(scope);
     return new DoEndBlock(new StatementBlock(statements));
 }
示例#2
0
        public LuaStatement Parse(INextAwareEnumerator <Token> reader, IParserContext context)
        {
            var scope = context.AcquireScope();

            reader.VerifyExpectedToken(Keywords.Do);
            reader.MoveNext();
            var statements = new List <LuaStatement>();

            while (reader.Current.Value != Keywords.End)
            {
                statements.Add(SyntaxParser.ReadStatement(reader, context));
            }
            reader.VerifyExpectedTokenAndMoveNext(Keywords.End);
            context.ReleaseScope(scope);
            return(new DoEndBlock(new StatementBlock(statements)));
        }
示例#3
0
        public override 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);
        }
示例#4
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));
        }