public T Visit(IASTNode node) { return(node switch { ASTType n => VisitASTType(n), ASTTypeField n => VisitASTTypeField(n), ASTTypeDefinition n => VisitASTTypeDefinition(n), ASTRestriction n => VisitASTRestriction(n), ASTAlias n => VisitASTAlias(n), ASTData n => VisitASTData(n), ASTAnnotation n => VisitASTAnnotation(n), ASTDirective n => VisitASTDirective(n), ASTChoice n => VisitASTChoice(n), ASTOption n => VisitASTOption(n), ASTChapter n => VisitASTChapter(n), ASTParagraph n => VisitASTParagraph(n), _ => VisitDefault(node), });
public IEnumerable <IASTNode> Parse() { List <ASTAnnotation> annotations = new List <ASTAnnotation>(); List <ASTDirective> directives = new List <ASTDirective>(); while (HasNext()) { if (Current.TokenType == TokenType.KW_Type) { var(errors, t) = ASTType.Parse(this, annotations, directives); this.Errors.AddRange(errors); yield return(t); } else if (Current.TokenType == TokenType.KW_Alias) { yield return(new ASTAlias(this)); } else if (Current.TokenType == TokenType.KW_Choice) { yield return(new ASTChoice(this)); } else if (Current.TokenType == TokenType.Annotation) { annotations = ASTAnnotation.Parse(this).ToList(); } else if (Current.TokenType == TokenType.Directive) { directives = ASTDirective.Parse(this).ToList(); } else { Next(); } } yield break; }
public IEnumerable <IASTNode> Parse() { var annotations = new List <ASTAnnotation>(); var directives = new List <ASTDirective>(); while (HasNext() && Current.TokenType != TokenType.EndOfFile) { if (Current.TokenType == TokenType.KW_Type) { var(errors, t) = ASTType.Parse(this, annotations, directives); Errors.AddRange(errors); annotations = new List <ASTAnnotation>(); directives = new List <ASTDirective>(); yield return(t); } else if (Current.TokenType == TokenType.KW_Alias) { var(errors, alias) = ASTAlias.Parse(this, annotations, directives); Errors.AddRange(errors); annotations = new List <ASTAnnotation>(); directives = new List <ASTDirective>(); yield return(alias); } else if (Current.TokenType == TokenType.KW_Choice) { var(errors, result) = ASTChoice.Parse(this); Errors.AddRange(errors); yield return(result); annotations = new List <ASTAnnotation>(); directives = new List <ASTDirective>(); } else if (Current.TokenType == TokenType.KW_Data) { var(errors, data) = ASTData.Parse(this, annotations, directives); Errors.AddRange(errors); yield return(data); annotations = new List <ASTAnnotation>(); directives = new List <ASTDirective>(); } else if (Current.TokenType == TokenType.KW_View) { var(errors, data) = ASTView.Parse(this, annotations, directives); Errors.AddRange(errors); yield return(data); annotations = new List <ASTAnnotation>(); directives = new List <ASTDirective>(); } else if (Current.TokenType == TokenType.KW_Open) { var(errors, data) = ASTImport.Parse(this); Errors.AddRange(errors); yield return(data); annotations = new List <ASTAnnotation>(); directives = new List <ASTDirective>(); } else if (Current.TokenType == TokenType.KW_Flow) { var(errors, data) = ASTFlow.Parse(this); Errors.AddRange(errors); yield return(data); annotations = new List <ASTAnnotation>(); directives = new List <ASTDirective>(); } else if (Current.TokenType == TokenType.Annotation) { annotations = ASTAnnotation.Parse(this).ToList(); } else if (Current.TokenType == TokenType.Directive) { var(errors, dirs) = ASTDirective.Parse(this); Errors.AddRange(errors.ToList()); directives = dirs.ToList(); } else if (Current.TokenType == TokenType.Chapter) { yield return(new ASTChapter(Current.Value)); Next(); } else if (Current.TokenType == TokenType.Paragraph) { yield return(new ASTParagraph(Current.Value)); Next(); } else { Next(); } } yield break; }
public override string VisitASTAnnotation(ASTAnnotation astAnnotation) { return(""); }
public override string VisitASTAnnotation(ASTAnnotation astAnnotation) { return($"@ {astAnnotation.Value}"); }
public override T VisitASTAnnotation(ASTAnnotation astAnnotation) => d;
public override XmlSchemaObject?VisitASTAnnotation(ASTAnnotation astAnnotation) { return(null); }