public override int VisitExpr_PLUSMINUS(firstParser.Expr_PLUSMINUSContext context) { int serial = ms_serialCounter++; string s = ""; switch (context.op.Type) { case firstParser.PLUS: s = "Plus_" + serial; // Preorder action outFile.WriteLine("\"{0}\"->\"{1}\";", m_labels.Peek(), s); break; case firstParser.MINUS: s = "Minus_" + serial; // Preorder action outFile.WriteLine("\"{0}\"->\"{1}\";", m_labels.Peek(), s); break; default: break; } m_labels.Push(s); base.VisitChildren(context); m_labels.Pop(); return(0); }
public override int VisitExpr_PLUSMINUS(firstParser.Expr_PLUSMINUSContext context) { ASTComposite m_parent = m_parents.Peek(); if (context.op.Type == firstParser.MINUS) { CASTSubtraction newnode = new CASTSubtraction(context.GetText(), nodeType.NT_SUBSTRACTION, m_parents.Peek(), 2); m_parent.AddChild(newnode, m_parentContext.Peek()); m_parents.Push(newnode); this.VisitElementInContext(context.expr(0), m_parentContext, contextType.CT_SUBSTRACTION_LEFT); this.VisitElementInContext(context.expr(1), m_parentContext, contextType.CT_SUBSTRACTION_RIGHT); } else if (context.op.Type == firstParser.PLUS) { CASTAddition newnode = new CASTAddition(context.GetText(), nodeType.NT_ADDITION, m_parents.Peek(), 2); m_parent.AddChild(newnode, m_parentContext.Peek()); m_parents.Push(newnode); this.VisitElementInContext(context.expr(0), m_parentContext, contextType.CT_ADDITION_LEFT); this.VisitElementInContext(context.expr(1), m_parentContext, contextType.CT_ADDITION_RIGHT); } m_parents.Pop(); return(0); }
public override int VisitExpr_PLUSMINUS(firstParser.Expr_PLUSMINUSContext context) { if (context.op.Type == firstParser.MINUS) { CASTSubtraction newNode = new CASTSubtraction(nodeType.NT_SUBTRACTION, m_parents.Peek(), 2); m_parents.Push(newNode); } else if (context.op.Type == firstParser.PLUS) { CASTAddition newNode = new CASTAddition(nodeType.NT_ADDITION, m_parents.Peek(), 2); m_parents.Push(newNode); } base.VisitExpr_PLUSMINUS(context); m_parents.Pop(); return(0); }