public ArrayList CALL_PARAMETERS(ParseTreeNode actual, ArrayList expresiones) { /* * CALL_PARAMETERS.Rule * = EXPRESION + CALL_PARAMETERS | COMA + EXPRESION + CALL_PARAMETERS | Empty | ; */ if (actual.ChildNodes.Count > 0) { if (actual.ChildNodes.Count == 2) { var expr = (expressionTraduccion.getExpresion(actual.ChildNodes[0])); expresiones.Add(expr); expresiones = CALL_PARAMETERS(actual.ChildNodes[1], expresiones); } else { var expr = expressionTraduccion.getExpresion(actual.ChildNodes[1]); expresiones.Add(expr); expresiones = CALL_PARAMETERS(actual.ChildNodes[2], expresiones); } } return(expresiones); }
public LinkedList <Expresion_Trad> WRITES(ParseTreeNode actual) { LinkedList <Expresion_Trad> list = new LinkedList <Expresion_Trad>(); if (actual.ChildNodes.Count > 0) { var exp = expressionAST.getExpresion(actual.ChildNodes[0]); list.AddLast(exp); list = WRHITE_PARAMETER(actual.ChildNodes[1], list); } return(list); }
public Switch_Trad 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]); var lista_cases = CASES(actual.ChildNodes[3], cant_tabs + 1); var else_case = CASE_ELSE(actual.ChildNodes[4], cant_tabs + 1); return(new Switch_Trad(condicion, lista_cases, else_case, cant_tabs)); }
public LinkedList <Instruction_Trad> LIST_DECLARATIONS(ParseTreeNode actual, LinkedList <Instruction_Trad> 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) { //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_Trad(identifier, "any", expressionAST.getExpresion(actual.ChildNodes[3]), true, cant_tabs, 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); }
public For_Trad 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]); var direccion = actual.ChildNodes[5].ChildNodes[0].Token.Text; var fin = expressionAST.getExpresion(actual.ChildNodes[6]); var lista_instrucciones = instructionAST.INSTRUCTIONS_BODY(actual.ChildNodes[8], cant_tabs + 1); return(new For_Trad(ident, inicio, fin, new Sentence_Trad(lista_instrucciones), direccion, cant_tabs)); }
public If_Trad IFTHEN(ParseTreeNode actual, int cant_tabs) { /* * IFTHEN.Rule * = RESERV_IF + EXPRESION + RESERV_THEN + IF_SENTENCE + ELIF; */ If_Trad ifs = new If_Trad(); ExpressionTraduccion expressionAST = new ExpressionTraduccion(); var LOGIC_EXPRESION = expressionAST.getExpresion(actual.ChildNodes[1]); var SENTENCES = IF_SENTENCE(actual.ChildNodes[3], cant_tabs + 1); var ELSE = ELIF(actual.ChildNodes[4], cant_tabs + 1); return(new If_Trad(LOGIC_EXPRESION, SENTENCES, ELSE, cant_tabs)); }