/
EvilBeaver
/
OneScript
Обзор
Документация
Войти
/
EvilBeaver
/
OneScript
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
develop
src/OneScript.Language/SyntaxAnalysis/PreprocessingLexer.cs
51 строка
1 KB
Andrey Ovsiankin
Выпиливание ParserContext (начало)
15 янв 2021, 16:40
15 янв 2021, 16:40
34c9ee1
Код
Авторство
О чём код?
/*---------------------------------------------------------- This Source Code Form is subject to the terms of the Mozilla Public License, v.2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ----------------------------------------------------------*/ using OneScript.Language.LexicalAnalysis; namespace OneScript.Language.SyntaxAnalysis { public class PreprocessingLexer : ILexer { private readonly ILexer _baseLexer; public PreprocessingLexer(ILexer baseLexer) { _baseLexer = baseLexer; } public PreprocessorHandlers Handlers { get; set; } public IErrorSink ErrorSink { get; set; } public Lexem NextLexem() { Lexem lex; while ((lex = _baseLexer.NextLexem()).Type == LexemType.PreprocessorDirective) { var handled = Handlers.HandleDirective(ref lex, this); if (handled) { return lex; } var err = LocalizedErrors.DirectiveNotSupported(lex.Content); err.Position = this.GetErrorPosition(); ErrorSink?.AddError(err); } return lex; } public SourceCodeIterator Iterator { get => _baseLexer.Iterator; set => _baseLexer.Iterator = value; } } }