Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. options
  2. {
  3. LOOKAHEAD= 1;
  4. MULTI = true;
  5. NODE_SCOPE_HOOK=true;
  6. }
  7.  
  8. PARSER_BEGIN(Reader)
  9.  
  10. public class Reader {
  11. Reader parser;
  12. public static void main(String args[]) throws ParseException {
  13. System.out.println("Java-- Parser");
  14. parser = new Reader(System.in);
  15.  
  16. try {
  17. parser.Global();
  18. System.out.println("Java-- Finished Parsing");
  19. } catch (ParseException e) {
  20. System.out.println(e.getMessage());
  21. System.out.println("Java-- Error Parsing");
  22. }
  23. }
  24. }
  25.  
  26. PARSER_END(Reader)
  27.  
  28. //White Spaces
  29.  
  30. SKIP :
  31. {
  32. " "
  33. | "\t"
  34. | "\n"
  35. | "\r"
  36. | "\f"
  37. }
  38.  
  39. //Keywords
  40.  
  41. TOKEN :
  42. {
  43.  
  44. < CLASS: "class" >
  45.  
  46. | < PUBLIC: "public" >
  47. | < STATIC: "static" >
  48.  
  49. | < NEW: "new" >
  50.  
  51. | < EXTENDS: "extends" >
  52.  
  53. | < FALSE: "false" >
  54. | < TRUE: "true" >
  55.  
  56. | < IF: "if" >
  57. | < ELSE: "else" >
  58.  
  59. | < BOOLEAN: "boolean" >
  60. | < INT: "int" >
  61.  
  62. | < RETURN: "return" >
  63.  
  64. | < VOID: "void" >
  65.  
  66. | < WHILE: "while" >
  67.  
  68. }
  69.  
  70. void Global() : {}
  71. {
  72. Class()
  73. <EOF>
  74. }
  75.  
  76. void Class() : {}
  77. {
  78.  
  79. ClassDeclaration()
  80.  
  81. ";"
  82.  
  83. }
  84.  
  85. void ClassDeclaration() : {}
  86. {
  87. ( "public" | "static" )*
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement