Exemple #1
0
 public Statement(IDebugTracer tracer, string prodName, Expression expression)
 {
     _tracer     = tracer;
     _prodName   = prodName;
     _expression = expression;
     NodeName    = "stmt" + ++_counter;
 }
Exemple #2
0
        public TerminalNode(IToken token, IDebugTracer tracer)
            : base(AstNodeType.Terminal, token, tracer)
        {
            Image = '"' + Image + '"';

            TermName = token.Image;
        }
Exemple #3
0
 protected AstNode(AstNodeType astNodeType, IToken token, IDebugTracer tracer)
 {
     AstNodeType = astNodeType;
     _tracer     = tracer;
     Location    = token.Location;
     NodeId      = $"{AstNodeType}{++NodeIdSuffix[AstNodeType]}";
     Image       = token.Image;
 }
Exemple #4
0
        private ISyntaxNode BuildTree(IDebugTracer tracer)
        {
            using var sb = new SyntaxBuilder(tracer);
            sb.Syntax("BeforeSyntax", "AfterSyntax",
                      sb.Statement("BeforeStmt", "AfterStmt", "<S>",
                                   sb.Expression("BeforeExpr", "AfterExpr",
                                                 sb.Term(
                                                     sb.Factor(sb.Terminal("a")),
                                                     sb.Factor(sb.ProdRef("<T>"))
                                                     ),
                                                 sb.Term("BeforeTerm", "AfterTerm",
                                                         sb.Factor("BeforeFactor", "AfterFactor",
                                                                   sb.Paren(
                                                                       sb.Expression(
                                                                           sb.Term(
                                                                               sb.Factor(sb.ProdRef("<U>"))
                                                                               )
                                                                           )
                                                                       )
                                                                   )
                                                         ),
                                                 sb.Term(
                                                     sb.Factor(
                                                         sb.Option(
                                                             sb.Expression(
                                                                 sb.Term(
                                                                     sb.Factor(sb.ProdRef("<V>"))
                                                                     )
                                                                 )
                                                             )
                                                         )
                                                     )
                                                 )
                                   ),
                      sb.Statement("<S>",
                                   sb.Expression(
                                       sb.Term(
                                           sb.Factor(
                                               sb.Kleene(
                                                   sb.Expression(
                                                       sb.Term(
                                                           sb.Factor(sb.ProdRef("<W>"))
                                                           )
                                                       )
                                                   )
                                               )
                                           )
                                       )
                                   )
                      );

            return(sb.BuildTree());
        }
Exemple #5
0
        public AstBuilder(IAstNodeFactory astNodeFactory,
                          IProdInfoFactory prodInfoFactory,
                          Stack <IAstNode> stack,
                          IDebugTracer tracer)
        {
            _astNodeFactory  = astNodeFactory;
            _prodInfoFactory = prodInfoFactory;
            _tracer          = tracer;

            _tokenDefinitions = new List <ITokenDefinition>();
            _stack            = stack;

            _tokenDefinitions = new List <ITokenDefinition>();
        }
Exemple #6
0
        private ISyntaxNode BuildTree(IDebugTracer tracer)
        {
            using var sb = new SyntaxBuilder(tracer);
            sb.Syntax(
                sb.Statement("<S>",
                             sb.Expression(
                                 sb.Term(
                                     sb.Factor(sb.Terminal("a")),
                                     sb.Factor(sb.ProdRef("<T>")),
                                     sb.Factor(sb.ProdRef("<U>"))
                                     )
                                 )
                             ),
                sb.Statement("<T>",
                             sb.Expression(
                                 sb.Term(
                                     sb.Factor(
                                         sb.Option(
                                             sb.Expression(
                                                 sb.Term(
                                                     sb.Factor(sb.Terminal("b"))
                                                     )
                                                 )
                                             )
                                         )
                                     )
                                 )
                             ),
                sb.Statement("<U>",
                             sb.Expression(
                                 sb.Term(
                                     sb.Factor(
                                         sb.Kleene(
                                             sb.Expression(
                                                 sb.Term(
                                                     sb.Factor(sb.Terminal("c"))
                                                     )
                                                 )
                                             )
                                         )
                                     )
                                 )
                             )
                );

            return(sb.BuildTree());
        }
Exemple #7
0
 public SyntaxBuilder(IDebugTracer tracer)
 {
     _tracer = tracer;
 }
Exemple #8
0
 public SyntaxNode(IToken token, IDebugTracer tracer)
     : base(AstNodeType.Syntax, token, tracer)
 {
 }
Exemple #9
0
 public void Setup()
 {
     _tracer = new Mock <IDebugTracer>().Object;
 }
Exemple #10
0
 public ActionNode(IToken token, IDebugTracer tracer)
     : base(AstNodeType.Action, token, tracer)
 {
     Image      = '#' + Image + '#';
     ActionName = token.Image;
 }
 public AstNodeFactory(IDebugTracer tracer)
 {
     _tracer = tracer;
 }
Exemple #12
0
 public Factor(IDebugTracer tracer, IFactExpr factExpr)
 {
     _tracer   = tracer;
     _factExpr = factExpr;
     NodeName  = "factor" + ++_counter;
 }
Exemple #13
0
 public Expression(IDebugTracer tracer, params Term[] terms)
 {
     _tracer  = tracer;
     _terms   = terms;
     NodeName = "expr" + ++_counter;
 }
Exemple #14
0
 public FactorNode(IToken token, IDebugTracer tracer)
     : base(AstNodeType.Factor, token, tracer)
 {
 }
Exemple #15
0
 public ProdRefNode(IToken token, IDebugTracer tracer)
     : base(AstNodeType.ProdRef, token, tracer)
 {
     ProdName = token.Image;
 }
Exemple #16
0
 public TermNode(IToken token, IDebugTracer tracer)
     : base(AstNodeType.Term, token, tracer)
 {
 }
Exemple #17
0
 public ExpressionNode(IToken token, IDebugTracer tracer)
     : base(AstNodeType.Expression, token, tracer)
 {
 }
Exemple #18
0
 public StatementNode(IToken token, IDebugTracer tracer)
     : base(AstNodeType.Statement, token, tracer)
 {
 }
Exemple #19
0
 public Syntax(IDebugTracer tracer, params Statement[] statements)
 {
     _tracer     = tracer;
     _statements = statements;
     NodeName    = "syntax" + ++_counter;
 }
Exemple #20
0
 public ProdRef(IDebugTracer tracer, string name)
 {
     _tracer  = tracer;
     _name    = name;
     NodeName = "prodRef" + ++_counter;
 }
Exemple #21
0
 public AstTraverser(IDebugTracer tracer)
 {
     _tracer = tracer;
 }
Exemple #22
0
 public Option(IDebugTracer tracer, Expression expr)
 {
     _tracer  = tracer;
     _expr    = expr;
     NodeName = "option" + ++_counter;
 }
Exemple #23
0
 public Term(IDebugTracer tracer, params Factor[] factors)
 {
     _tracer  = tracer;
     _factors = factors;
     NodeName = "term" + ++_counter;
 }
Exemple #24
0
 public ProductionInfo(string name, IDebugTracer tracer)
 {
     _tracer   = tracer;
     Name      = name;
     Statement = null;
 }
Exemple #25
0
 public Terminal(string image, IDebugTracer tracer)
 {
     _tracer  = tracer;
     _image   = image;
     NodeName = "terminal" + ++_counter;
 }
Exemple #26
0
 public ParenNode(IToken token, IDebugTracer tracer)
     : base(AstNodeType.Paren, token, tracer)
 {
 }
Exemple #27
0
 public Paren(IDebugTracer tracer, Expression expr)
 {
     _tracer  = tracer;
     _expr    = expr;
     NodeName = "paren" + ++_counter;
 }
Exemple #28
0
 public OptionNode(IToken token, IDebugTracer tracer)
     : base(AstNodeType.Option, token, tracer)
 {
 }
Exemple #29
0
 public Kleene(IDebugTracer tracer, Expression expr)
 {
     _tracer  = tracer;
     _expr    = expr;
     NodeName = "kleene" + ++_counter;
 }
Exemple #30
0
 public KleeneNode(IToken token, IDebugTracer tracer)
     : base(AstNodeType.KleeneStar, token, tracer)
 {
 }