aboutsummaryrefslogtreecommitdiff
path: root/demos/sample-files/parser-skeleton.c
diff options
context:
space:
mode:
authorkartofen <mladenovnasko0@gmail.com>2025-07-03 19:11:36 +0300
committerkartofen <mladenovnasko0@gmail.com>2025-07-03 19:11:36 +0300
commitf2bef76fb369d4c9c3e53dca60eb78b75bb02d97 (patch)
tree94de181d7dae1d35310e1e9bfbf761b0fc536adf /demos/sample-files/parser-skeleton.c
parent5064a7ebce75a26d0405c92040f1a40187fcc7e3 (diff)
working more or less parser generator (no semantic action, so pretty much useless
Diffstat (limited to 'demos/sample-files/parser-skeleton.c')
-rw-r--r--demos/sample-files/parser-skeleton.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/demos/sample-files/parser-skeleton.c b/demos/sample-files/parser-skeleton.c
new file mode 100644
index 0000000..facbc1b
--- /dev/null
+++ b/demos/sample-files/parser-skeleton.c
@@ -0,0 +1,30 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "lr-parser.c"
+#include "bin/generated.c"
+
+#include "parts/toklist.h"
+
+enum symbol {
+ PLUS = 0,
+ MINUS,
+ LPAREN,
+ RPAREN,
+ N0, N1,
+ END_INPUT,
+
+ EP, E, T, N,
+ SYMBOLS_END,
+};
+
+static symbol toklist[] = {N0, PLUS, N1, END_INPUT};
+static symbol *tok = toklist;
+
+symbol toklist_eat() { return *(tok++); } // unsafe
+symbol toklist_peek() { return *tok; } // unsafe
+
+int main(void)
+{
+ return lr_parser();
+}