예제 #1
0
 public static string GetNamespace(this SyntaxNodeModel model, List <SyntaxNodeModel> models)
 {
     return(model.GetParent(models).Match(
                parent => $"Nord.Compiler.Generated.Ast.{parent.GetName().Pluralize()}",
                () => "Nord.Compiler.Generated.Ast"
                ));
 }
예제 #2
0
        public static SyntaxNodeModel GetBase(this SyntaxNodeModel model, List <SyntaxNodeModel> models)
        {
            var rootOption = model.GetRootParent(models);

            return(rootOption.Match(
                       root => root,
                       () => model
                       ));
        }
예제 #3
0
        public static Option <SyntaxNodeModel> GetRootParent(this SyntaxNodeModel model, List <SyntaxNodeModel> models)
        {
            var parent = model.GetParent(models);
            var root   = parent.Map(p => p.GetRootParent(models).ValueUnsafe());

            return(root.Match(
                       r => r,
                       () => parent
                       ));
        }
예제 #4
0
 public static string GetClassName(this SyntaxNodeModel model)
 {
     return($"Syntax{model.Name.Pascalize()}");
 }
예제 #5
0
 public static string GetName(this SyntaxNodeModel model)
 {
     return(model.Name);
 }
예제 #6
0
 public static Option <SyntaxNodeModel> GetParent(this SyntaxNodeModel model, List <SyntaxNodeModel> models)
 {
     return(model.Parent.Map(p => models.FirstOrDefault(m => m.Name == p)));
 }