aboutsummaryrefslogtreecommitdiff
path: root/demos/sample-files/defs.c
diff options
context:
space:
mode:
Diffstat (limited to 'demos/sample-files/defs.c')
-rw-r--r--demos/sample-files/defs.c49
1 files changed, 0 insertions, 49 deletions
diff --git a/demos/sample-files/defs.c b/demos/sample-files/defs.c
deleted file mode 100644
index 76a0534..0000000
--- a/demos/sample-files/defs.c
+++ /dev/null
@@ -1,49 +0,0 @@
-#include <stdio.h>
-#include <stddef.h>
-
-#include "parts/symbol.h"
-enum symbol {
- PLUS = 0,
- MINUS,
- LPAREN,
- RPAREN,
- N0, N1,
- END_INPUT,
-
- EP, E, T, N,
- SYMBOLS_END,
-};
-
-size_t total_symbols = SYMBOLS_END;
-
-IMPLEMENT_FUNCPTR(int, symbol_is_terminal, (symbol s), { return s < EP; })
-IMPLEMENT_FUNCPTR(int, symbol_is_input_end, (symbol s), { return s == END_INPUT; })
-IMPLEMENT_FUNCPTR(int, symbol_is_valid,(symbol s), { return s < SYMBOLS_END; })
-
-#include "parts/grammar.h"
-#define PROD(LHS, _, ...) {LHS, (symbol[]){__VA_ARGS__}, sizeof((symbol[]){__VA_ARGS__})/sizeof(symbol)}
-static struct production _grammar[] = {
- PROD(EP, ->, E, END_INPUT),
- PROD(E, -->, E, PLUS, T),
- PROD(E, -->, E, MINUS, T),
- PROD(E, -->, T),
- PROD(T, -->, LPAREN, E, RPAREN),
- PROD(T, -->, N),
- PROD(N, -->, N0),
- PROD(N, -->, N1),
-};
-
-struct production *grammar = _grammar;
-size_t total_productions = sizeof(_grammar)/sizeof(*_grammar);
-
-// #include "???.h"
-char **semantic_action_str = (char *([])){
- "v = A(0);",
- "v = A(0) + A(2);",
- "v = A(0) - A(2);",
- "v = A(0);",
- "v = A(1);",
- "v = A(0);",
- "v = 0;",
- "v = 1;",
-};