示例#1
0
        // ECMA-262 13.9 The break statement

        public Node parseBreakStatement(Node node)
        {
            Node label = null;
            string key;

            expectKeyword("break");

            // Catch the very common case first: immediately a semicolon (U+003B).
            if (source.ToCharArray()[lastIndex] == 0x3B)
            {
                lex();

                if (!(state.inIteration || state.inSwitch))
                {
                    throwError(Messages.IllegalBreak);
                }

                return node.finishBreakStatement(null);
            }

            if (hasLineTerminator)
            {
                if (!(state.inIteration || state.inSwitch))
                {
                    throwError(Messages.IllegalBreak);
                }

                return node.finishBreakStatement(null);
            }

            if (lookahead.type == TokenType.Identifier)
            {
                label = parseVariableIdentifier();

                //key = "$" + label.name;
                //if (!Object.prototype.hasOwnProperty.call(state.labelSet, key)) {
                //    throwError(Messages.UnknownLabel, label.name);
                //}
            }

            consumeSemicolon();

            if (label == null && !(state.inIteration || state.inSwitch))
            {
                throwError(Messages.IllegalBreak);
            }

            return node.finishBreakStatement(label);
        }