public void Visit(NExpr nExpr) { Visit((dynamic)nExpr[0]); if (nExpr.children.Count >= 2) { Visit((dynamic)nExpr[1]); Visit((dynamic)nExpr[2]); } }
// Returns NExpr or any of subproduction nodes public Node Expr() { Node resultingNode = ExprOr(); if (CurrentToken == TokenCategory.QUESTION_MARK) { NExpr tmp = new NExpr(); tmp.Add(resultingNode); Expect(TokenCategory.QUESTION_MARK); tmp.Add(Expr()); Expect(TokenCategory.COLON); tmp.Add(Expr()); resultingNode = tmp; } return(resultingNode); }
public string Visit(NExpr nExpr) { string retVal = Visit((dynamic)nExpr[0]); if (nExpr.children.Count == 3) { string falseCase = GenerateLabel(); retVal += "\t\tbrfalse " + falseCase + "\n"; string exitTernary = GenerateLabel(); retVal += Visit((dynamic)nExpr[1]); retVal += "\t\tbr " + exitTernary + "\n"; retVal += falseCase + ":\n"; retVal += Visit((dynamic)nExpr[2]); retVal += exitTernary + ":\n"; } return(retVal); }
//------------------------------------------------------------ public void Visit(NExpr node) { Console.WriteLine($"+++++++++++++++ NExpr ++++++++++++++++"); //VisitChildren(node); }