Ejemplo n.º 1
0
        /// <summary>
        /// Выбор обработчика для токена
        /// </summary>
        private void ProcessDirective()
        {
            _iterator.MoveNext();
            _iterator.IsTokenType(TokenTypeEnum.IDENTIFIER);


            foreach (DirectiveBase directive in _directives)
            {
                if (directive.ProcessDirective())
                {
                    return;
                }
            }

            throw new CompilerException(_iterator.Current.CodeInformation, $"Оператор препроцессора #{_iterator.Current.Content} не распознан.");
        }
Ejemplo n.º 2
0
        public override bool MoveNext()
        {
            _iterator.MoveNext();

            _precompiler.Process();

            _token = _iterator.Current;
            if (_token.Content == "\0")
            {
                _precompiler.Error();
                return(false);
            }

            if (_token == null)
            {
                throw new CompilerException(_iterator.Current.CodeInformation, "Не удалось получить токен.");
            }

            if (_precompiler.IsDirective())
            {
                throw new Exception("Есть не обработанная директива.");
            }

            return(true);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Список найденых токенов.
        /// </summary>
        /// <returns>Список найденых лексем и их токенов</returns>
        public IList <IToken> GetAllTokens()
        {
            IToken            token      = null;
            IList <IToken>    token_list = new List <IToken>();
            TokenIteratorBase iterator   = GetEnumerator();

            do
            {
                iterator.MoveNext();
                token = iterator.Current;
                token_list.Add(token);
            }while (token.Content != "\0");

            return(token_list);
        }