示例#1
0
        private IOperationCollection pushLoop(Scope scope)
        {
            if (_iterator.Is(TokenType.Name))
            {
                switch (_iterator.GetValue <string>())
                {
                case "if": return(pushSingleInstruction_if(scope));

                case "for": return(pushSingleInstruction_for(scope));

                case "while": return(pushSingleInstruction_while(scope));

                case "do": return(pushSingleInstruction_do_repeat(scope, true));

                case "repeat": return(pushSingleInstruction_do_repeat(scope, false));
                }
            }

            return(pushTerminatedInstruction(scope));
        }
示例#2
0
        /// <summary>
        /// Reads a namespace path (tokens separated by '::') from the tokenizer.
        /// </summary>
        /// <returns>a list containing the several parts of the path.</returns>
        private List <string> ReadNamespacePath()
        {
            List <string> ns = new List <string>();

            // Read namespace name
            if (!_iterator.Is(TokenType.Name))
            {
                throw new SyntaxException(_iterator.Position, "Expected namespace name");
            }
            ns.Add(_iterator.GetValue <string>());
            _iterator.Next();

            // And potential parent namespaces
            while (_iterator.Is(TokenType.DoubleColon))
            {
                _iterator.Next();
                if (!_iterator.Is(TokenType.Name))
                {
                    throw new SyntaxException(_iterator.Position, "Expected namespace name");
                }
                ns.Add(_iterator.GetValue <string>());
                _iterator.Next();
            }

            return(ns);
        }