Advertisement
Guest User

Untitled

a guest
Jan 11th, 2017
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. package parsery.interpreter;
  2.  
  3. import java_cup.runtime.*;
  4.  
  5. parser code {:
  6.  
  7. public static InterpreterUnix unix = new InterpreterUnix();
  8.  
  9. public void syntax_error(Symbol token)
  10. {
  11. report_error("Blad skladniowy ",token);
  12. }
  13.  
  14.  
  15. public void report_error(String message, Object info)
  16. {
  17. StringBuffer m = new StringBuffer(message);
  18.  
  19. if (info instanceof java_cup.runtime.Symbol)
  20. {
  21. java_cup.runtime.Symbol s = (java_cup.runtime.Symbol) info;
  22.  
  23. if (s.left >= 0)
  24. {
  25. m.append("w wierszu "+(s.left+1));
  26. if (s.right>=0) m.append(" w kolumnie "+(s.right+1));
  27. }
  28. }
  29.  
  30. System.err.println("BLAD "+m);
  31. }
  32.  
  33.  
  34. public void report_fatal_error(String message, Object info)
  35. {
  36. report_error("KRYTYCZNY "+message, info);
  37. }
  38.  
  39. :};
  40.  
  41.  
  42.  
  43. /* ------------Declaration of Terminals and Non Terminals Section----------- */
  44.  
  45.  
  46. terminal DATE;
  47. non terminal komenda, polecenie,polecenieDATE;
  48.  
  49.  
  50.  
  51. /* ----------------------------Grammar Section-------------------- */
  52.  
  53. /*
  54. komenda ::= polecenie
  55. polecenieDATE ::= DATE
  56. */
  57.  
  58. komenda ::= polecenie:p
  59. {: RESULT = p; :}
  60. ;
  61.  
  62. polecenie ::= polecenieDATE:pDATE
  63. {: RESULT = pDATE; :}
  64. ;
  65. polecenieDATE::= DATE:date
  66. {: RESULT = parser.unix.polecenieDATE(""); :}
  67. ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement