From eb007d554251456a2a508849edf91b15aab1333e Mon Sep 17 00:00:00 2001 From: JSDurand Date: Mon, 31 Jan 2022 15:59:11 +0800 Subject: cnp: save point Now we need to implement predicates, in order to have practical applications. --- src/grammar.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/grammar.c') diff --git a/src/grammar.c b/src/grammar.c index 3b5a959..afb9353 100644 --- a/src/grammar.c +++ b/src/grammar.c @@ -44,6 +44,15 @@ rg_nth(CCR_MOD(Rule_group *) rg, NUM n) return (List *) list_nth(rg->rights, n); } +struct PT_DATA_s { + dfa *dfap; + /* NULL-terminated strings */ + char *user_name; + char *raw_name; +}; + +typedef struct PT_DATA_s PTD; + /* TODO: Add some statistic counts to assist the hash tables. For example, store the total number of terminals as an integer; then the hash table can be hinted at initialization to contain that many @@ -63,7 +72,8 @@ struct Grammar_s { To print them, first encode them into normal strings. */ List *names; - /* TODO: Add an array of predicates. */ + /* an array of predicates. */ + PTD *predicates; }; static void @@ -179,6 +189,7 @@ BOOL build_grammar(Grammar *g, const List *rules, CC_MOD(List *) names) { g->names = (List *) names; + g->predicates = NULL; NUM len = list_length(names); NUM rule_len = list_length(rules); -- cgit v1.2.3-18-g5258