blob: d6f33e7e378afa52670130676553d68ceefbd824 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
%{
#include <stdio.h>
#include <stdlib.h>
extern char* yytext;
%}
%token tSkip tChain tSlip tSingle tHalfDouble tDouble tTriple tStartBlock tEndBlock tNum tErr
%%
start: start input
| input
;
input: stitch
| tNum stitch
| block
| tNum block
;
stitch: tSkip
| tChain
| tSlip
| tSingle
| tHalfDouble
| tDouble
| tTriple
;
block: tStartBlock start tEndBlock
;
%%
int yyerror(char* s) {
if (yytext[0]==10) printf("!!SYNTAX ERROR!! Token read was NEWLINE.\n");
else if (yytext[0]=='\0') printf("!!SYNTAX ERROR!! Unexpected end of input.\n");
else printf("!!SYNTAX ERROR!! Token read was \"%s\".\n", yytext);
}
int main() {
return yyparse();
}
|