public override Node VisitArithmetic([NotNull] TigerParser.ArithmeticContext context) { ArithmeticNode node; switch (context.op.Text) { case "*": node = new MulNode(context); break; case "/": node = new DivNode(context); break; case "+": node = new PlusNode(context); break; case "-": node = new MinusNode(context); break; default: throw new NotSupportedException(); } node.Children.Add(Visit(context.expr(0))); // LEFT EXPRESSION node.Children.Add(Visit(context.expr(1))); // RIGHT EXPRESSION return(node); }
public CalculatorApplicationNode(ITestObject parent, AppModelBase applicationModel) : base(parent, applicationModel) { Zero = new ZeroNode(this, applicationModel); Plus = new PlusNode(this, applicationModel); Seven = new SevenNode(this, applicationModel); MobileObjectUiObject = new MobileObjectUiObjectNode(this, applicationModel); DisplayName = @"Calculator"; }
public static Node BuildExpr() { MultNode tn = new MultNode(); PlusNode pn = new PlusNode(); pn.left = new IntNode (5); pn.right = new IntNode (4); tn.left = pn; tn.right = pn; return tn; }
public static Node BuildExpr() { MultNode tn = new MultNode(); PlusNode pn = new PlusNode(); pn.left = new IntNode(5); pn.right = new IntNode(4); tn.left = pn; tn.right = pn; return(tn); }
public override ASTN VisitAddsub([NotNull] AddsubContext context) { ExprNode Leftexpr = (VisitExpr(context.left) as ExprNode); ExprNode Rigthexpr = (VisitExpr(context.right) as ExprNode); AritmethicNode node; if (context.op.Type == ADD) { node = new PlusNode(context); } else { node = new ResNode(context); } node.Leftexpr = Leftexpr; node.Rigthexpr = Rigthexpr; return(node); }
public void Visit(PlusNode node) { VisitChildren(node); builder.AppendLine("\t\tadd.ovf"); }
public Type Visit(PlusNode node) { VisitBinaryOperator(node, Type.INT); return(Type.INT); }
/// <summary> /// This method type checks the PlusNode node in the AST. /// </summary> /// <param name="plusNode">The node to check.</param> /// <returns>Plus operator type context</returns> public override object Visit(PlusNode plusNode) { return(new TypeContext(OP_PLUS)); }
private ValInfo Visit(PlusNode node) { return(BinaryOperator(node, (x, y) => x + y)); }
private VarType Parsing(PlusNode node, string methodName) { return ParseElementaryOperation(node, methodName); }
// throws RecognitionException [1] // $ANTLR end "expr_comp" // $ANTLR start "expr_pm" // C:\\Users\\Danaice\\Desktop\\lastversion\\Dany_gramatica tiger ANTLR oficial\\tiger_grammar.g:141:1: expr_pm returns [TigerNode pm] : exp1= expr_dm ( MAS a= expr_dm | MENOS b= expr_dm )* ; public TigerNode expr_pm() { TigerNode pm = null; IToken MAS10 = null; IToken MENOS11 = null; TigerNode exp1 = null; TigerNode a = null; TigerNode b = null; try { // C:\\Users\\Danaice\\Desktop\\lastversion\\Dany_gramatica tiger ANTLR oficial\\tiger_grammar.g:141:31: (exp1= expr_dm ( MAS a= expr_dm | MENOS b= expr_dm )* ) // C:\\Users\\Danaice\\Desktop\\lastversion\\Dany_gramatica tiger ANTLR oficial\\tiger_grammar.g:141:33: exp1= expr_dm ( MAS a= expr_dm | MENOS b= expr_dm )* { PushFollow(FOLLOW_expr_dm_in_expr_pm938); exp1 = expr_dm(); state.followingStackPointer--; if (state.failed) return pm; if ( (state.backtracking==0) ) { pm = exp1; } // C:\\Users\\Danaice\\Desktop\\lastversion\\Dany_gramatica tiger ANTLR oficial\\tiger_grammar.g:142:28: ( MAS a= expr_dm | MENOS b= expr_dm )* do { int alt5 = 3; int LA5_0 = input.LA(1); if ( (LA5_0 == MAS) ) { alt5 = 1; } else if ( (LA5_0 == MENOS) ) { alt5 = 2; } switch (alt5) { case 1 : // C:\\Users\\Danaice\\Desktop\\lastversion\\Dany_gramatica tiger ANTLR oficial\\tiger_grammar.g:142:30: MAS a= expr_dm { MAS10=(IToken)Match(input,MAS,FOLLOW_MAS_in_expr_pm971); if (state.failed) return pm; PushFollow(FOLLOW_expr_dm_in_expr_pm975); a = expr_dm(); state.followingStackPointer--; if (state.failed) return pm; if ( (state.backtracking==0) ) { pm = new PlusNode(pm, a); pm.Col=MAS10.CharPositionInLine; pm.Row = MAS10.Line; } } break; case 2 : // C:\\Users\\Danaice\\Desktop\\lastversion\\Dany_gramatica tiger ANTLR oficial\\tiger_grammar.g:147:30: MENOS b= expr_dm { MENOS11=(IToken)Match(input,MENOS,FOLLOW_MENOS_in_expr_pm1009); if (state.failed) return pm; PushFollow(FOLLOW_expr_dm_in_expr_pm1013); b = expr_dm(); state.followingStackPointer--; if (state.failed) return pm; if ( (state.backtracking==0) ) { pm = new MinusNode(pm, b); pm.Col=MENOS11.CharPositionInLine; pm.Row = MENOS11.Line; } } break; default: goto loop5; } } while (true); loop5: ; // Stops C# compiler whining that label 'loop5' has no statements } } catch (RecognitionException re) { ReportError(re); Recover(input,re); } finally { } return pm; }
/// <summary> /// This visits a plus node /// </summary> /// <param name="plusNode">The visited node</param> /// <returns></returns> public abstract object Visit(PlusNode plusNode);
public PlusNodeViewModel(PlusNode plusNode) : base(plusNode) { }
public double CalcPlusNode(PlusNode node) { return((double)+node.token.value); }
private TypeInfo Visit(PlusNode node, MethodBuilder builder, CodegenContext context) { return(BinaryOperatorVisit(node, builder, (x) => x.Plus(), context)); }
/// <summary> /// This method prints the plusNode /// </summary> /// <param name="plusNode">The node to print.</param> /// <returns>Returns null</returns> public override object Visit(PlusNode plusNode) { Print("PlusNode"); return(null); }
/// <summary> /// This method visits a plus node /// </summary> /// <param name="plusNode">The name of the node</param> /// <returns>It returns a "+" </returns> public override object Visit(PlusNode plusNode) { return(" + "); }
private void Parsing(PlusNode node, StringBuilder sb, ref int lineNum) { Parsing(node.GetChild(0) as dynamic, sb, ref lineNum); Parsing(node.GetChild(1) as dynamic, sb, ref lineNum); PrintCommand(sb, "add", ref lineNum); }
private TypeDescriptor Visit(PlusNode node, Context context) { return(MathOperator(node, context)); }