public ArrayList CALL_PARAMETERS(ParseTreeNode actual, ArrayList expresiones, int cant_tabs)
        {
            /*
             * CALL_PARAMETERS.Rule
             *  = EXPRESION + CALL_PARAMETERS
             | COMA + EXPRESION + CALL_PARAMETERS
             | Empty
             |  ;
             */
            if (actual.ChildNodes.Count > 0)
            {
                if (actual.ChildNodes.Count == 2)
                {
                    var expr = (expressionAST.getExpresion(actual.ChildNodes[0], cant_tabs));
                    expresiones.Add(expr);
                    expresiones = CALL_PARAMETERS(actual.ChildNodes[1], expresiones, cant_tabs);
                }

                else
                {
                    var expr = expressionAST.getExpresion(actual.ChildNodes[1], cant_tabs);

                    expresiones.Add(expr);

                    expresiones = CALL_PARAMETERS(actual.ChildNodes[2], expresiones, cant_tabs);
                }
            }
            return(expresiones);
        }
        public Instruction ARRAYs(ParseTreeNode actual, string name, int cant_tabs)
        {
            /*
             * ARRAY.Rule =
             * RESERV_ARRAY  + COR_IZQ + EXPLOGICA + PUNTO + PUNTO + EXPLOGICA + MORE_ARRAY
             + COR_DER + RESERV_OF + DATA_TYPE + PUNTO_COMA;
             */

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


            var limit_inf = expressionAST.getExpresion(actual.ChildNodes[2], cant_tabs);
            var limit_sup = expressionAST.getExpresion(actual.ChildNodes[5], cant_tabs);


            LinkedList <Dimention> lista_actual = new LinkedList <Dimention>();

            lista_actual.AddLast(new Dimention(limit_inf, limit_sup, row, col, cant_tabs, 1));
            lista_actual = MORE_ARRAY(actual.ChildNodes[6], lista_actual, cant_tabs, 2);

            var data_type = GetDataType(actual.ChildNodes[9].ChildNodes[0].ToString());

            return(new Array(name, lista_actual, data_type, row, col, cant_tabs));
        }
        public LinkedList <Expresion> WRITES(ParseTreeNode actual, int cant_tabs)
        {
            LinkedList <Expresion> list = new LinkedList <Expresion>();

            if (actual.ChildNodes.Count > 0)
            {
                var exp = ExpresionAST.getExpresion(actual.ChildNodes[0], cant_tabs);
                list.AddLast(exp);
                list = WRHITE_PARAMETER(actual.ChildNodes[1], list, cant_tabs);
            }
            return(list);
        }
        public LinkedList <Instruction> LIST_DECLARATIONS(ParseTreeNode actual, LinkedList <Instruction> lista_actual, ArrayList elementos_her, int cant_tabs)
        {
            /*
             * DECLARATION_LIST.Rule
             * = RESERV_VAR + IDENTIFIER + DECLARATION_BODY + VAR_DECLARATION + DECLARATION_LIST
             | Empty
             | ;
             */

            if (actual.ChildNodes.Count != 0)
            {
                int row = actual.ChildNodes[0].Token.Location.Line;
                int col = actual.ChildNodes[0].Token.Location.Column;
                //VERIFICA SI ES VAR O CONST
                var tipo = actual.ChildNodes[0];

                //ES CONST
                if (tipo.Term.ToString().Equals("RESERV_CONST"))
                {
                    var identifier = actual.ChildNodes[1].Token.Text;
                    lista_actual.AddLast(new Declaration(identifier, expressionAST.getExpresion(actual.ChildNodes[3], cant_tabs), row, col, true, false));
                    lista_actual = CONST_DECLARATION(actual.ChildNodes[5], lista_actual, elementos_her, cant_tabs);
                    lista_actual = LIST_DECLARATIONS(actual.ChildNodes[6], lista_actual, elementos_her, cant_tabs);
                }
                //ES VAR
                else
                {
                    var identifier = actual.ChildNodes[1].Token.Text;
                    elementos_her.Add(identifier);

                    lista_actual = DECLARATION_BODY(actual.ChildNodes[2], lista_actual, elementos_her, cant_tabs);
                    lista_actual = VAR_DECLARATION(actual.ChildNodes[3], lista_actual, elementos_her, cant_tabs);
                    lista_actual = LIST_DECLARATIONS(actual.ChildNodes[4], lista_actual, elementos_her, cant_tabs);
                }

                return(lista_actual);
            }


            return(lista_actual);
        }
Exemple #5
0
        public Switch SENTENCE_CASE(ParseTreeNode actual, int cant_tabs)
        {
            /*
             *  SENTENCE_CASE.Rule = RESERV_CASE  + LOGIC_EXPRESION + RESERV_OF + CASES + CASE_ELSE + RESERV_END + PUNTO_COMA;
             *
             * CASE_ELSE.Rule = RESERV_ELSE + INSTRUCTIONS
             | Empty
             |  ;
             */

            var       condicion   = expressionAST.getExpresion(actual.ChildNodes[1], cant_tabs);
            ArrayList lista_cases = new ArrayList();

            lista_cases = CASES(actual.ChildNodes[3], lista_cases, cant_tabs);

            var else_case = CASE_ELSE(actual.ChildNodes[4], cant_tabs);

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

            return(new Switch(condicion, lista_cases, else_case, row, column, cant_tabs));
        }
Exemple #6
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));
        }
        public If IFTHEN(ParseTreeNode actual, int cant_tabs)
        {
            /*
             * IFTHEN.Rule
             *  = RESERV_IF + EXPRESION
             + RESERV_THEN
             + IF_SENTENCE
             + ELIF;
             */
            If           ifs           = new If();
            ExpresionAST expressionAST = new ExpresionAST();
            var          row           = actual.ChildNodes[0].Token.Location.Line;
            var          col           = actual.ChildNodes[0].Token.Location.Column;

            var LOGIC_EXPRESION = expressionAST.getExpresion(actual.ChildNodes[1], cant_tabs);
            var SENTENCES       = IF_SENTENCE(actual.ChildNodes[3], cant_tabs);
            var ELSE            = ELIF(actual.ChildNodes[4], cant_tabs);

            return(new If(LOGIC_EXPRESION, SENTENCES, ELSE, row, col, cant_tabs));
        }