/
EvilBeaver
/
OneScript
Обзор
Документация
Войти
/
EvilBeaver
/
OneScript
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
v2.0.3-alpha
src/OneScript.Language.Tests/TestAstNode.cs
55 строк
2 KB
Andrey Ovsiankin
Переименовал MethodInfo в MethodSignature
04 июн 2021, 14:51
04 июн 2021, 14:51
3a46d7e
Код
Авторство
О чём код?
/*---------------------------------------------------------- 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; using System.Collections.Generic; using System.Linq; using OneScript.Language.SyntaxAnalysis.AstNodes; namespace OneScript.Language.Tests { public class TestAstNode : BslSyntaxNode { private Lazy<IReadOnlyList<TestAstNode>> _childrenLazy; public BslSyntaxNode RealNode { get; } public TestAstNode(BslSyntaxNode node) { RealNode = node; Kind = node.Kind; if (node is NonTerminalNode nonTerm) { _childrenLazy = new Lazy<IReadOnlyList<TestAstNode>>(nonTerm.Children.Select(x => new TestAstNode(x)).ToArray()); Value = nonTerm switch { AnnotationNode anno => anno.Name, BinaryOperationNode binary => binary.Operation.ToString(), UnaryOperationNode unary => unary.Operation.ToString(), PreprocessorDirectiveNode preproc => preproc.DirectiveName, _ => Value }; } else if(node is TerminalNode term) { _childrenLazy = new Lazy<IReadOnlyList<TestAstNode>>(new TestAstNode[0]); Value = term.Lexem.Content; } } public string Value { get; set; } public IReadOnlyList<TestAstNode> ChildrenList => _childrenLazy.Value; public override IReadOnlyList<BslSyntaxNode> Children => ChildrenList; public override string ToString() { return $"{Kind} ({Location.LineNumber},{Location.ColumnNumber})"; } } }