From 7ccd9286bafbd01fbda67c2f234998c2e591ed2a Mon Sep 17 00:00:00 2001 From: kartofen Date: Thu, 17 Jul 2025 01:27:05 +0300 Subject: ok precedence --- lr-parser.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lr-parser.c') diff --git a/lr-parser.c b/lr-parser.c index 827b502..799276d 100644 --- a/lr-parser.c +++ b/lr-parser.c @@ -93,7 +93,7 @@ size_t total_symbols = 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), 0} +#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), @@ -105,6 +105,9 @@ static struct production _grammar[] = { PROD(N, -->, N1), }; +int *precedence_symbol = (int[]){0}; +int *precedence_production = (int[]){0}; + struct production *grammar = _grammar; size_t total_productions = sizeof(_grammar)/sizeof(*_grammar); -- cgit v1.2.3