Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- grammar csce322a01part01;
- // rules
- extremePegSolitaire: validGame validMoves endOfFile EOF | validMoves validGame endOfFile EOF | error;
- validGame: gameTitle sectionBeginning gameStart validBoard gameEnd sectionEnding;
- validMoves: movesTitle sectionBeginning movesStart validMovelist movesEnd sectionEnding;
- validBoard: nonFinalRow+ validRow;
- validRow: trueGameSymbol+;
- nonFinalRow: validRow rowEnd;
- validMovelist: moveSymbol+;
- //tokens as rules
- gameTitle: GAME_TITLE{
- System.out.println("game Section");
- };
- movesTitle: MOVES_TITLE{
- System.out.println("moves Section");
- };
- sectionBeginning: SECTION_BEGINNING{
- System.out.println("Begin the Section");
- };
- sectionEnding: SECTION_ENDING{
- System.out.println("End the Section");
- };
- gameStart: GAME_START{
- System.out.println("Start the Game");
- };
- gameEnd: GAME_END{
- System.out.println("End the Game");
- };
- movesStart: MOVES_START{
- System.out.println("Begin the List");
- };
- movesEnd: MOVES_END{
- System.out.println("End the List");
- };
- moveSymbol: MOVE_SYMBOL COMMAS*{
- System.out.println("Move: " + $MOVE_SYMBOL.text);
- };
- gameSymbol: GAME_SYMBOL{
- System.out.println("Space: " + $GAME_SYMBOL.text);
- };
- emptySpace: EMPTY_SPACE{
- System.out.println("Space: Empty");
- };
- rowEnd: ROW_END{
- System.out.println("End the Row");
- };
- endOfFile:{
- System.out.println("End the File");
- };
- error: ERROR{System.out.println("SYNTAX ERROR IN LINE " + $ANYTHING.line); System.exit(0);};
- trueGameSymbol: emptySpace | gameSymbol;
- // tokens
- GAME_TITLE: '!game';
- MOVES_TITLE: '!moves';
- SECTION_BEGINNING: '>>';
- SECTION_ENDING: '<<';
- GAME_START: '{';
- GAME_END: '}';
- MOVES_START: '^';
- MOVES_END: '$';
- MOVE_SYMBOL: 'u'|'d'|'l'|'r';
- GAME_SYMBOL: 'x'|[0-9]+;
- EMPTY_SPACE: '-';
- ROW_END: '*';
- COMMAS: ',';
- WHITE_SPACE: [ \t\r\n]+ -> skip;
- ERROR: .;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement