From 8995097a1d5fc9ce837252ec2829125311cc3236 Mon Sep 17 00:00:00 2001 From: "Sven M. Hallberg" <pesco@khjk.org> Date: Sat, 5 Sep 2015 22:43:49 +0200 Subject: [PATCH] let's just use ((void *)-1) as another invalid pointer result --- src/backends/llk.c | 5 ++--- src/cfgrammar.c | 4 ++-- src/cfgrammar.h | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/backends/llk.c b/src/backends/llk.c index 95289975..b0959985 100644 --- a/src/backends/llk.c +++ b/src/backends/llk.c @@ -276,8 +276,7 @@ typedef struct { // execute on their corresponding result. // also on the stack below the mark, we store the previously accumulated // value for the surrounding production. -static int dummy; -static void *MARK = &dummy; // stack frame delimiter +static void *MARK = (void *)-1; // stack frame delimiter static HLLkState *llk_parse_start_(HAllocator* mm__, const HParser* parser) { @@ -329,7 +328,7 @@ static HCountedArray *llk_parse_chunk_(HLLkState *s, const HParser* parser, const HCFSequence *p = h_llk_lookup(table, x, stream); if(p == NULL) goto no_parse; - if(p == H_NEED_INPUT) + if(p == NEED_INPUT) goto need_input; // an infinite loop case that shouldn't happen diff --git a/src/cfgrammar.c b/src/cfgrammar.c index 117009a5..a7601e11 100644 --- a/src/cfgrammar.c +++ b/src/cfgrammar.c @@ -349,7 +349,7 @@ void *h_stringmap_get(const HStringMap *m, const uint8_t *str, size_t n, bool en return m->epsilon_branch; } -// A NULL result means no parse. H_NEED_INPUT means lookahead is too short. +// A NULL result means no parse. NEED_INPUT means lookahead is too short. void *h_stringmap_get_lookahead(const HStringMap *m, HInputStream lookahead) { while(m) { @@ -368,7 +368,7 @@ void *h_stringmap_get_lookahead(const HStringMap *m, HInputStream lookahead) // XXX assumption of byte-wise grammar and input return m->end_branch; } else { - return H_NEED_INPUT; + return NEED_INPUT; } } diff --git a/src/cfgrammar.h b/src/cfgrammar.h index 2294d445..1e18442d 100644 --- a/src/cfgrammar.h +++ b/src/cfgrammar.h @@ -57,7 +57,7 @@ static inline HStringMap *h_stringmap_get_char(const HStringMap *m, const uint8_ { return h_hashtable_get(m->char_branches, (void *)char_key(c)); } // dummy return value used by h_stringmap_get_lookahead when out of input -#define H_NEED_INPUT ((void *)&h_stringmap_get_lookahead) +#define NEED_INPUT ((void *)-1) /* Convert 'parser' into CFG representation by desugaring and compiling the set -- GitLab