diff options
author | Nat Lasseter <Nat Lasseter nathan@bytemark.co.uk> | 2017-06-11 22:50:09 +0100 |
---|---|---|
committer | Nat Lasseter <Nat Lasseter nathan@bytemark.co.uk> | 2017-06-11 22:50:09 +0100 |
commit | d43994ebc260ea0ad6cd82c929059a44f998a782 (patch) | |
tree | d78dd42544cc86372636bf85c13539fee1897822 /ocml.y |
Diffstat (limited to 'ocml.y')
-rw-r--r-- | ocml.y | 42 |
1 files changed, 42 insertions, 0 deletions
@@ -0,0 +1,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(); +} |