public LinkedList <Instruction> IF_SENTENCE(ParseTreeNode actual, int cant_tabs)
        {
            /*
             * IF_SENTENCE.Rule = INSTRUCTIONS_BODY
             | Empty
             |  ;
             */

            if (actual.ChildNodes.Count == 0)
            {
                return(new LinkedList <Instruction>());
            }

            return(instructionAST.INSTRUCTIONS_BODY(actual.ChildNodes[0], cant_tabs + 1));
        }
Exemple #2
0
        public LinkedList <Instruction> getFunciones(ParseTreeNode actual,
                                                     LinkedList <Instruction> lista_funciones, ArrayList parametros_her, int cant_tabs)
        {
            /*
             * FUNCTION_LIST.Rule
             *  = RESERV_FUNCTION + IDENTIFIER + PAR_IZQ + PARAMETER + PAR_DER + DOS_PUNTOS + DATA_TYPE + PUNTO_COMA
             + DECLARATION_LIST_HIJA
             + FUNCION_HIJA
             + INSTRUCTIONS_BODY
             + PUNTO_COMA
             + FUNCTION_LIST
             | Empty
             |  ;
             */
            LinkedList <Instruction> parametros     = new LinkedList <Instruction>();
            LinkedList <Instruction> declaraciones  = new LinkedList <Instruction>();
            LinkedList <Instruction> fuciones_hijas = new LinkedList <Instruction>();

            var row = actual.ChildNodes[0].Token.Location.Line;
            var col = actual.ChildNodes[0].Token.Location.Column;


            var reserv_fun = actual.ChildNodes[0].Token.Text;

            var identifier = actual.ChildNodes[1].Token.Text;

            parametros = PARAMETER(actual.ChildNodes[3], parametros, parametros_her);

            var function_type = actual.ChildNodes[6].ChildNodes[0].Token.Text;

            declaraciones = declarationAST.LIST_DECLARATIONS(actual.ChildNodes[8], declaraciones, new ArrayList(), cant_tabs + 1);

            fuciones_hijas = FUNCION_HIJA(actual.ChildNodes[9], fuciones_hijas, cant_tabs, identifier);

            var function_instructions = instructionAST.INSTRUCTIONS_BODY(actual.ChildNodes[10], cant_tabs + 1);

            lista_funciones.AddLast(new Function(identifier, parametros, declaraciones, fuciones_hijas, function_type,
                                                 function_instructions, false, identifier, row, col, false));


            parametros_her.Clear();

            lista_funciones = FUNCTION_LIST(actual.ChildNodes[12], lista_funciones, parametros_her, cant_tabs);

            return(lista_funciones);
        }
        public While WHILE(ParseTreeNode actual, int cant_tabs)
        {
            //WHILE.Rule = RESERV_WHILE + LOGIC_EXPRESION + RESERV_DO + INSTRUCTIONS_BODY;

            var condition = (new ExpresionAST()).getExpresion(actual.ChildNodes[1], cant_tabs);

            int row = actual.ChildNodes[0].Token.Location.Line;
            int col = actual.ChildNodes[0].Token.Location.Column;


            InstructionAST instructionAST = new InstructionAST();

            LinkedList <Instruction> lista_instrucciones = instructionAST.INSTRUCTIONS_BODY(actual.ChildNodes[3], cant_tabs + 1);

            return(new While(condition, new Sentence(lista_instrucciones), row, col, cant_tabs));
        }
Exemple #4
0
        public For SENCECIA_FOR(ParseTreeNode actual, int cant_tabs)
        {
            /*
             * FOR.Rule
             *  = RESERV_FOR + IDENTIFIER + DOS_PUNTOS + EQUALS + LOGIC_EXPRESION + TODOWN + LOGIC_EXPRESION
             + RESERV_DO
             + INSTRUCTIONS_BODY //+ PUNTO_COMA
             +  ;
             + TODOWN.Rule
             +  = RESERV_TO
             | RESERV_DOWN + RESERV_TO
             |  ;
             */
            var ident               = actual.ChildNodes[1].Token.Text;
            var inicio              = expressionAST.getExpresion(actual.ChildNodes[4], cant_tabs);
            var direccion           = actual.ChildNodes[5].ChildNodes[0].Token.Text;
            var fin                 = expressionAST.getExpresion(actual.ChildNodes[6], cant_tabs);
            var lista_instrucciones = instructionAST.INSTRUCTIONS_BODY(actual.ChildNodes[8], cant_tabs + 1);
            var row                 = actual.ChildNodes[0].Token.Location.Line;
            var col                 = actual.ChildNodes[0].Token.Location.Column;

            return(new For(ident, inicio, fin, lista_instrucciones, direccion, row, col, cant_tabs));
        }