diff options
Diffstat (limited to 'src/cnp.h')
-rw-r--r-- | src/cnp.h | 61 |
1 files changed, 60 insertions, 1 deletions
@@ -1,4 +1,63 @@ #ifndef CNP_H #define CNP_H -/* TODO */ +#include "str.h" +#include "utf8.h" +#include "bsr.h" +#include "crf.h" + +/* We start with implementing some support functions. These support + functions are not supposed to be put in the crf.h header file, as + they are not related to the underlying (static) data structures + really. */ + +typedef struct Environment_s Environment; + +/* On error return NULL */ +Environment *new_env(Grammar *g, str *string); + +HP_ATTR BOOL env_error_p(CCR_MOD(Environment *) env); + +P_ATTR bsr *env_bsrp(CCR_MOD(Environment *) env); + +P_ATTR Grammar *env_grammar(CCR_MOD(Environment *) env); + +HP_ATTR crf *env_crfp(CCR_MOD(Environment *) env); + +HP_ATTR procr *env_r(CCR_MOD(Environment *) env); +HP_ATTR procu *env_u(CCR_MOD(Environment *) env); +H_ATTR void env_str(CCR_MOD(Environment *) env, + NUM **str, NUM *str_len); + +H_ATTR BOOL env_follow_p(CCR_MOD(Environment *) env, NUM X, NUM t); + +void env_print_follow(CCR_MOD(Environment *) env, NUM X); + +void env_print_first(CCR_MOD(Environment *) env, NUM X); + +/* Convenient macro */ + +#define CHECK_ENV_ERROR(ENV, CLEANUP) do { \ + if (env_error_p(ENV)) { \ + fleprintf0("Error occurs!\n"); \ + { CLEANUP }; \ + } \ + } while (0) + +/* NOTE: Since the grammar pointer just points to the existing grammar + when we construct it, we shall not destroy the grammar when we + destroy the environment, so that we can later reuse that grammar, + should the need arise. */ +void destroy_env(Environment *env); + +void nt_add(Environment *env, NUM X, NUM j); + +BOOL test_select(Environment *env, NUM b, NUM X, + CCR_MOD(List *) tnts); + +void rtn(Environment *env, NUM X, NUM k, NUM j); + +void cnp_call(Environment *env, pair3 label, NUM i, NUM j); + +/* TODO: Main algorithm */ + #endif |