aboutsummaryrefslogtreecommitdiff
path: root/lr-parser.c
diff options
context:
space:
mode:
Diffstat (limited to 'lr-parser.c')
-rw-r--r--lr-parser.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/lr-parser.c b/lr-parser.c
index 2358164..9f7ea24 100644
--- a/lr-parser.c
+++ b/lr-parser.c
@@ -1,6 +1,9 @@
#include <stdio.h>
#include <stdlib.h>
+// TODO: check erros and fail safely and
+// see connection with the lexer
+
// Requirements
#include "parts/symbol.h"
#include "parts/grammar.h"
@@ -74,11 +77,11 @@ enum symbol {
size_t total_symbols = SYMBOLS_END;
-int symbol_is_valid(symbol s) { return s < SYMBOLS_END; }
+IMPLEMENT_FUNCPTR(int, symbol_is_valid, (symbol s), { return s < SYMBOLS_END; })
// implement grammar.h
#define PROD(LHS, _, ...) {LHS, (symbol[]){__VA_ARGS__}, sizeof((symbol[]){__VA_ARGS__})/sizeof(symbol)}
-struct production grammar[] = {
+static struct production _grammar[] = {
PROD(EP, ->, E, END_INPUT),
PROD(E, -->, E, PLUS, T),
PROD(E, -->, E, MINUS, T),
@@ -89,7 +92,8 @@ struct production grammar[] = {
PROD(N, -->, N1),
};
-const size_t total_productions = sizeof(grammar)/sizeof(*grammar);
+struct production *grammar = _grammar;
+size_t total_productions = sizeof(_grammar)/sizeof(*_grammar);
// implement table.h
struct action **table = (struct action *([])){