Advertisement
Guest User

Param

a guest
May 24th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. public ArrayList<Param> param(){
  2.  
  3. Variable v;
  4. ArrayList<Param> pa = new ArrayList<Param>();
  5.  
  6. if (lexer.token != Symbol.LPAR)
  7. error.signal("'LPAR' expected");
  8.  
  9. lexer.nextToken();
  10. if (lexer.token != Symbol.RPAR){
  11.  
  12. do {
  13.  
  14. String id;
  15. Type tipo = null;
  16.  
  17. if(lexer.token == Symbol.COMMA)
  18. lexer.nextToken();
  19.  
  20. if(lexer.token == Symbol.STRING){
  21. tipo = Type.string_type;
  22. } else if (lexer.token == Symbol.INT){
  23. tipo = Type.int_type;
  24. } else if(lexer.token == Symbol.FLOAT){
  25. tipo = Type.float_type;
  26. }
  27.  
  28. lexer.nextToken();
  29. id = lexer.getStringValue();
  30. lexer.nextToken();
  31.  
  32. v = new Variable(id, tipo, "0"); //checar o valor, por enquanto vou colocar 0 como padrão
  33. pa.add(new Param(v));
  34. hashTable.putInLocal(id, v);
  35.  
  36. } while (lexer.token == Symbol.COMMA);
  37.  
  38. if (lexer.token != Symbol.RPAR)
  39. error.signal("'RPAR' expected");
  40. }
  41.  
  42. lexer.nextToken();
  43.  
  44. return pa;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement