/
EvilBeaver
/
OneScript
Обзор
Документация
Войти
/
EvilBeaver
/
OneScript
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
v2.0.1
src/OneScript.Language/LexicalAnalysis/LexerExtensions.cs
48 строк
1 KB
Andrey Ovsiankin
Новое АПИ входа в модуль. Заменено в тестах
22 июл 2021, 14:31
22 июл 2021, 14:31
3b770c0
Код
Авторство
О чём код?
/*---------------------------------------------------------- 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 System; namespace OneScript.Language.LexicalAnalysis { public static class LexerExtensions { public static int ReadToLineEnd(this ILexer lexer) { var data = lexer.Iterator.ReadToLineEnd(); return data.Length; } public static Lexem NextLexemOnSameLine(this ILexer lexer) { if (lexer.Iterator.CurrentSymbol == '\n') { return Lexem.EndOfText(); } try { lexer.Iterator.StayOnSameLine = true; return lexer.Iterator.MoveToContent() ? lexer.NextLexem() : Lexem.EndOfText(); } finally { lexer.Iterator.StayOnSameLine = false; } } public static void SkipTillLineEnd(this ILexer lexer) { lexer.ReadToLineEnd(); } public static Lexem SkipTillNextStatement(this ILexer lexer) { throw new NotImplementedException(); } } }