Advertisement
Guest User

Untitled

a guest
Jan 11th, 2017
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. package parsery.interpreter;
  2.  
  3. import java_cup.runtime.*;
  4.  
  5. %%
  6.  
  7. %class MyLexer
  8.  
  9.  
  10. %line
  11. %column
  12.  
  13. %cup
  14.  
  15. %{
  16.  
  17. private Symbol symbol(int type) {
  18. return new Symbol(type, yyline, yycolumn);
  19. }
  20.  
  21. private Symbol symbol(int type, Object value) {
  22. return new Symbol(type, yyline, yycolumn, value);
  23. }
  24. %}
  25.  
  26. LineTerminator = \r|\n|\r\n
  27.  
  28. WhiteSpace = {LineTerminator} | [ \t\f]
  29.  
  30. DATE = "date" | "DATE"
  31.  
  32.  
  33. %%
  34.  
  35. /* ------------------------Lexical Rules Section---------------------- */
  36.  
  37.  
  38. <YYINITIAL> {
  39.  
  40. {DATE} { return symbol(sym.DATE, new String(yytext())); }
  41. {WhiteSpace} { }
  42.  
  43. }
  44.  
  45.  
  46. [^] { throw new Error("Nieoczekiwany znak <"+yytext()+">"); }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement