aboutsummaryrefslogtreecommitdiff
path: root/parts/grammar.h
diff options
context:
space:
mode:
authorkartofen <mladenovnasko0@gmail.com>2025-07-01 00:11:29 +0300
committerkartofen <mladenovnasko0@gmail.com>2025-07-01 00:11:29 +0300
commita67266ff72280b85fed7ec498967a855a5735639 (patch)
treef53d551e49e2263b5208b9adf1d4c50943f4d59d /parts/grammar.h
parent7743cb4f8a06ab79a521c4346aac74b47c8ce224 (diff)
major refactor, more modular (wow because obviously modularity is always a good thing yes), and etc
Diffstat (limited to 'parts/grammar.h')
-rw-r--r--parts/grammar.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/parts/grammar.h b/parts/grammar.h
new file mode 100644
index 0000000..328f88e
--- /dev/null
+++ b/parts/grammar.h
@@ -0,0 +1,22 @@
+#ifndef GRAMMAR_H
+#define GRAMMAR_H
+
+extern struct production {
+ symbol LHS;
+ symbol *RHS;
+ size_t nRHS;
+} grammar[];
+
+extern const size_t total_productions;
+
+void grammar_print()
+{
+ for(size_t i = 0; i < total_productions; i++) {
+ printf("%d --> ", grammar[i].LHS);
+ for(size_t j = 0; j < grammar[i].nRHS; j++)
+ printf("%d ", grammar[i].RHS[j]);
+ printf("\n");
+ }
+}
+
+#endif