Expresiones parexp() { if (currentToken.Tipo == TipoToken.TK_OPENPAR) { currentToken = lex.NextToken(); Expresiones tmp; try { tmp = Expr(); } catch (Exception ex) { throw ex; } if (currentToken.Tipo == TipoToken.TK_CLOSEPAR) { currentToken = lex.NextToken(); return tmp; } else throw new Exception("Se esperaba )"); } else if (currentToken.Tipo == TipoToken.TK_NOT) { currentToken = lex.NextToken(); try { return new Not(Expr()); } catch (Exception ex) { throw ex; } } else if (currentToken.Tipo == TipoToken.TK_ID) { string tmp = currentToken.Lexema; currentToken = lex.NextToken(); if (currentToken.Tipo == TipoToken.TK_OPENPAR) { ExprFuncion ret = new ExprFuncion(); ret.ID = new Variable(tmp, null); ret.VarList = new ListaExpre(); try { ret.VarList.Ex = ExprList(); } catch (Exception ex) { throw ex; } if (currentToken.Tipo != TipoToken.TK_CLOSEPAR) throw new Exception("Se esperaba )."); else { currentToken = lex.NextToken(); return ret; } } else { try { return new Variable(tmp, AccessList(tmp)); } catch (Exception ex) { throw ex; } } } else return LIT(); }
public Expresiones Parexp() { try { if (currentToken.Tipo == Lexico.TipoToken.TK_INT_LIT) { LiteralEntero lit = new LiteralEntero(Convert.ToInt32(currentToken.Lexema)); currentToken = lex.NextToken(); return lit; } else if (currentToken.Tipo == Lexico.TipoToken.TK_FLOAT_LIT) { LiteralFlotante lit = new LiteralFlotante(float.Parse(currentToken.Lexema)); currentToken = lex.NextToken(); return lit; } else if (currentToken.Tipo == Lexico.TipoToken.TK_CHAR_LIT) { LitChar lit = new LitChar(currentToken.Lexema); currentToken = lex.NextToken(); return lit; } else if (currentToken.Tipo == Lexico.TipoToken.TK_STRING_LIT) { LitString lit = new LitString(currentToken.Lexema); currentToken = lex.NextToken(); return lit; } else if (currentToken.Tipo == Lexico.TipoToken.TK_TRUE) { LitBool lit = new LitBool(true); currentToken = lex.NextToken(); return lit; } else if (currentToken.Tipo == Lexico.TipoToken.TK_FALSE) { LitBool lit = new LitBool(false); currentToken = lex.NextToken(); return lit; } else if (currentToken.Tipo == Lexico.TipoToken.TK_ID) { ExprFuncion V = new ExprFuncion(); V.ID = new Variable(currentToken.Lexema, null); currentToken = lex.NextToken(); if (currentToken.Tipo == Lexico.TipoToken.TK_PUNTO || currentToken.Tipo == Lexico.TipoToken.TK_ID || currentToken.Tipo == Lexico.TipoToken.TK_OPENPAR || currentToken.Tipo == Lexico.TipoToken.TK_OPENCOR) { try { V.ID.accesor = Accesories(V.ID.accesor); Access tmp = ((Access)V.ID.accesor); if (tmp.Next != null) { tmp = tmp.Last(); } if (V.ID.accesor != null && tmp is AccessFunc) { AccessFunc v = ((AccessFunc)tmp); V.VarList = v.Variables; return V; } else return V.ID; } catch (Exception ex) { throw ex; } } else { return V.ID; } } return null; /* ExprFuncion V = new ExprFuncion(); V.ID = new Variable(currentToken.Lexema, null); currentToken = lex.NextToken(); V.ID.accesor = Accesories(V.ID.accesor); if (V.ID.accesor != null) return V; else return V.ID; */ // return null; } catch (Exception ex) { throw ex; } }