summaryrefslogtreecommitdiff
path: root/ocml.y
diff options
context:
space:
mode:
authorNat Lasseter <Nat Lasseter nathan@bytemark.co.uk>2017-06-11 22:50:09 +0100
committerNat Lasseter <Nat Lasseter nathan@bytemark.co.uk>2017-06-11 22:50:09 +0100
commitd43994ebc260ea0ad6cd82c929059a44f998a782 (patch)
treed78dd42544cc86372636bf85c13539fee1897822 /ocml.y
Initial CommitHEADmaster
Diffstat (limited to 'ocml.y')
-rw-r--r--ocml.y42
1 files changed, 42 insertions, 0 deletions
diff --git a/ocml.y b/ocml.y
new file mode 100644
index 0000000..d6f33e7
--- /dev/null
+++ b/ocml.y
@@ -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();
+}