Beispiel #1
0
 public override void Parse(Context context)
 {
     if (context.Consume(Tokenizer.TokenKind.MINUS))
     {
         var subZero = new AdditionNode();
         var zero    = new NumericLiteralNode();
         zero.Number      = 0;
         subZero.LeftSide = zero;
         var right = new PrimaryNode();
         right.Parse(context);
         subZero.RightSides.Add(
             new Tuple <Tokenizer.TokenKind, Node>(Tokenizer.TokenKind.MINUS, right)
             );
         this.Node = subZero;
         return;
     }
     context.Consume(Tokenizer.TokenKind.PLUS);
     this.Node = new PrimaryNode();
     this.Node.Parse(context);
 }
Beispiel #2
0
 public override void Visit(NumericLiteralNode node)
 {
     this.Add($"   push {node.Number}");
 }
 public abstract void Visit(NumericLiteralNode node);