From 5426d9e2a6b820e34809d639838b26643df9ab17 Mon Sep 17 00:00:00 2001 From: JSDurand Date: Tue, 8 Feb 2022 00:29:10 +0800 Subject: fix errors There are multiple subtle errors in the previous version, both in the codes and in the description of the BNF format. This version should fix some problems now. This version can successfully parse the grammar of its own grammar format, which is quite nice. See test/check_reader.c for parsing this format. --- src/grammar.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/grammar.h') diff --git a/src/grammar.h b/src/grammar.h index 89a66ba..bf418e0 100644 --- a/src/grammar.h +++ b/src/grammar.h @@ -75,6 +75,8 @@ typedef struct PT_DATA_s PTD; /* On error return NULL */ PTD *new_ptd(str *user_name, str *raw_name, dfa *dfap); +P_ATTR str *ptd_user_name(PTD *p); + /* FLAG is used to destroy the strings contained within */ void destroy_ptd(PTD *p, int flag); @@ -134,6 +136,8 @@ find_in_cpa_list(CCR_MOD(NUM *) string, NUM size, /* assume element is a cpa pointer */ void print_name(void *element); +void eprint_name(void *element); + void print_tnt(void *element); void print_rule(void *r); @@ -167,9 +171,10 @@ void destroy_rule_no_free(void *rule); void destroy_cpa_and_free_all(void *element); void destroy_grammar(void *grammar, int flag); -NUM grammar_left_len(CCR_MOD(Grammar *)g); +P_ATTR NUM grammar_left_len(CCR_MOD(Grammar *)g); -List *grammar_names(CCR_MOD(Grammar *)g); +P_ATTR List *grammar_names(CCR_MOD(Grammar *)g); +P_ATTR List *grammar_preds(CCR_MOD(Grammar *)g); /* look up a rule */ Rule_group *grammar_rule(CCR_MOD(Grammar *) g, NT nt); -- cgit v1.2.3-18-g5258