2020-10-01 13:14:57 +05:30
|
|
|
grammar bfe;
|
2020-09-29 23:16:42 +05:30
|
|
|
|
2020-09-30 00:50:00 +05:30
|
|
|
program
|
2020-09-30 16:54:58 +05:30
|
|
|
: statements? EOF;
|
2020-09-30 00:50:00 +05:30
|
|
|
|
|
|
|
statements
|
2020-09-30 16:54:58 +05:30
|
|
|
: eligibleStmt+;
|
2020-09-30 00:50:00 +05:30
|
|
|
|
2020-09-30 16:54:58 +05:30
|
|
|
eligibleStmt
|
|
|
|
: stmt
|
|
|
|
| numberedStmt
|
2020-09-30 00:50:00 +05:30
|
|
|
;
|
|
|
|
|
2020-09-30 16:54:58 +05:30
|
|
|
numberedStmt
|
|
|
|
: stmt NUMBER
|
2020-09-30 00:50:00 +05:30
|
|
|
;
|
|
|
|
|
2020-09-30 16:54:58 +05:30
|
|
|
|
|
|
|
stmt
|
|
|
|
: basicStmt
|
|
|
|
| groupedStmt
|
|
|
|
| loopStmt
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
|
|
groupedStmt
|
|
|
|
: GRPSTART statements GRPEND
|
|
|
|
;
|
|
|
|
|
|
|
|
loopStmt
|
|
|
|
: LOOPSTART statements LOOPEND
|
|
|
|
;
|
|
|
|
|
|
|
|
basicStmt
|
|
|
|
: ptrIncr
|
|
|
|
| ptrDecr
|
|
|
|
| ptrLeft
|
|
|
|
| ptrRight
|
2020-09-30 00:50:00 +05:30
|
|
|
| inputStmt
|
|
|
|
| outputStmt
|
|
|
|
;
|
|
|
|
|
2020-09-30 16:54:58 +05:30
|
|
|
|
|
|
|
ptrIncr
|
|
|
|
: INC
|
|
|
|
;
|
|
|
|
|
|
|
|
ptrDecr
|
|
|
|
: DEC
|
|
|
|
;
|
|
|
|
|
|
|
|
ptrLeft
|
|
|
|
: LEFT
|
|
|
|
;
|
|
|
|
|
|
|
|
ptrRight
|
|
|
|
: RIGHT
|
|
|
|
;
|
|
|
|
|
2020-09-30 00:50:00 +05:30
|
|
|
inputStmt
|
|
|
|
: INPUT
|
|
|
|
;
|
|
|
|
|
|
|
|
outputStmt
|
|
|
|
: OUTPUT
|
2020-09-29 23:30:58 +05:30
|
|
|
;
|
2020-09-29 23:16:42 +05:30
|
|
|
|
2020-09-29 23:30:58 +05:30
|
|
|
NEWLINE: '\n' -> skip;
|
2020-09-30 00:50:00 +05:30
|
|
|
COMMENT: '//' ~[\r\n]* '\r'? '\n'? -> channel(HIDDEN);
|
|
|
|
WS: [ \r\n] -> skip;
|
2020-09-30 16:54:58 +05:30
|
|
|
DEF: '#';
|
2020-09-30 00:50:00 +05:30
|
|
|
LOOPSTART: '[';
|
|
|
|
LOOPEND:']';
|
2020-09-30 16:54:58 +05:30
|
|
|
GRPSTART:'(';
|
|
|
|
GRPEND:')';
|
2020-09-30 00:50:00 +05:30
|
|
|
NUMBER: [0-9]+;
|
2020-09-29 23:16:42 +05:30
|
|
|
INPUT: '?';
|
|
|
|
OUTPUT: '.';
|
|
|
|
DEC: '-';
|
|
|
|
INC: '+';
|
|
|
|
LEFT: '>';
|
|
|
|
RIGHT: '<';
|