Ejemplo n.º 1
0
        private Statement ParseLoopFlowControlStatement()
        {
            if (!_inLoop)
            {
                string name;
                TokenKind kind = NextToken().Kind;
                if (kind == TokenKind.KeywordBreak)
                    name = "break";
                else
                    name = "continue";
                ReportSyntaxError("'" + name + "' outside loop.");
                return null;
            }

            Statement ret;
            switch (NextToken().Kind)
            {
                case TokenKind.KeywordBreak:
                    ret = new BreakStatement();
                    break;

                case TokenKind.KeywordContinue:
                    ret = new ContinueStatement();
                    break;

                default:
                    throw Assert.Unreachable;
            }

            var start = GetStart();
            Eat(TokenKind.Semicolon);
            ret.SetLoc(_globalParent, start, GetEnd());
            return ret;
        }
Ejemplo n.º 2
0
        public override bool Walk(ContinueStatement node)
        {
            node.Parent = _currentScope;
            node.LoopStatement = _loops[_loops.Count - 1];

            return base.Walk(node);
        }