Advertisement
Guest User

Untitled

a guest
Feb 19th, 2020
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. grammar csce322a01part01;
  2.  
  3. // rules
  4. extremePegSolitaire: validGame validMoves endOfFile EOF | validMoves validGame endOfFile EOF | error;
  5. validGame: gameTitle sectionBeginning gameStart validBoard gameEnd sectionEnding;
  6. validMoves: movesTitle sectionBeginning movesStart validMovelist movesEnd sectionEnding;
  7. validBoard: nonFinalRow+ validRow;
  8. validRow: trueGameSymbol+;
  9. nonFinalRow: validRow rowEnd;
  10. validMovelist: moveSymbol+;
  11.  
  12. //tokens as rules
  13. gameTitle: GAME_TITLE{
  14. System.out.println("game Section");
  15. };
  16. movesTitle: MOVES_TITLE{
  17. System.out.println("moves Section");
  18. };
  19. sectionBeginning: SECTION_BEGINNING{
  20. System.out.println("Begin the Section");
  21. };
  22. sectionEnding: SECTION_ENDING{
  23. System.out.println("End the Section");
  24. };
  25. gameStart: GAME_START{
  26. System.out.println("Start the Game");
  27. };
  28. gameEnd: GAME_END{
  29. System.out.println("End the Game");
  30. };
  31. movesStart: MOVES_START{
  32. System.out.println("Begin the List");
  33. };
  34. movesEnd: MOVES_END{
  35. System.out.println("End the List");
  36. };
  37. moveSymbol: MOVE_SYMBOL COMMAS*{
  38. System.out.println("Move: " + $MOVE_SYMBOL.text);
  39. };
  40. gameSymbol: GAME_SYMBOL{
  41. System.out.println("Space: " + $GAME_SYMBOL.text);
  42. };
  43. emptySpace: EMPTY_SPACE{
  44. System.out.println("Space: Empty");
  45. };
  46. rowEnd: ROW_END{
  47. System.out.println("End the Row");
  48. };
  49. endOfFile:{
  50. System.out.println("End the File");
  51. };
  52. error: ERROR{System.out.println("SYNTAX ERROR IN LINE " + $ANYTHING.line); System.exit(0);};
  53. trueGameSymbol: emptySpace | gameSymbol;
  54.  
  55. // tokens
  56. GAME_TITLE: '!game';
  57. MOVES_TITLE: '!moves';
  58. SECTION_BEGINNING: '>>';
  59. SECTION_ENDING: '<<';
  60. GAME_START: '{';
  61. GAME_END: '}';
  62. MOVES_START: '^';
  63. MOVES_END: '$';
  64. MOVE_SYMBOL: 'u'|'d'|'l'|'r';
  65. GAME_SYMBOL: 'x'|[0-9]+;
  66. EMPTY_SPACE: '-';
  67. ROW_END: '*';
  68. COMMAS: ',';
  69. WHITE_SPACE: [ \t\r\n]+ -> skip;
  70. ERROR: .;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement