コード例 #1
0
        public override string VisitASTFlow(ASTFlow astFlow)
        {
            var result = new MermaidFlowMapper(astFlow).ToString();

            this.Parts.Add(result);
            return(result);
        }
コード例 #2
0
 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),
         ASTFlow n => VisitASTFlow(n),
         _ => VisitDefault(node),
     });
コード例 #3
0
ファイル: Parser.cs プロジェクト: lucashorward/ZDragon.NET
        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;
        }
コード例 #4
0
 public MermaidFlowMapper(ASTFlow flow)
 {
     this.Flow = flow;
 }
コード例 #5
0
 public override T VisitASTFlow(ASTFlow astFlow) => d;
コード例 #6
0
 public override string VisitASTFlow(ASTFlow astFlow) => throw new NotImplementedException();
コード例 #7
0
 public override XmlSchemaObject?VisitASTFlow(ASTFlow astFlow)
 {
     return(null);
 }
コード例 #8
0
 public override string VisitASTFlow(ASTFlow astFlow)
 {
     return("");
 }