public void Visit(NExpr nExpr)
 {
     Visit((dynamic)nExpr[0]);
     if (nExpr.children.Count >= 2)
     {
         Visit((dynamic)nExpr[1]);
         Visit((dynamic)nExpr[2]);
     }
 }
Exemplo n.º 2
0
        // 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);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
//------------------------------------------------------------
        public void Visit(NExpr node)
        {
            Console.WriteLine($"+++++++++++++++ NExpr ++++++++++++++++");

            //VisitChildren(node);
        }