1
0
forked from GitHub/gf-core

Use a separated tag for meta productions in the robust parser. This cleans up the code a lot

This commit is contained in:
kr.angelov
2012-06-13 05:49:30 +00:00
parent cc58e2d05f
commit 3ad5493758
5 changed files with 296 additions and 189 deletions

View File

@@ -66,7 +66,12 @@ gu_make_buf(size_t elem_size, GuPool* pool)
return buf;
}
static const GuWord gu_empty_seq[2] = {0, 0};
static const GuWord gu_empty_seq_[2] = {0, 0};
GuSeq
gu_empty_seq() {
return (GuSeq) { gu_tagged((void*)&gu_empty_seq_[1], 0) };
}
GuSeq
gu_make_seq(size_t elem_size, size_t length, GuPool* pool)
@@ -76,7 +81,7 @@ gu_make_seq(size_t elem_size, size_t length, GuPool* pool)
void* buf = gu_malloc(pool, size);
return (GuSeq) { gu_tagged(buf, length) };
} else if (size == 0) {
return (GuSeq) { gu_tagged((void*)&gu_empty_seq[1], 0) };
return gu_empty_seq();
} else {
void* buf = gu_malloc_prefixed(pool,
gu_alignof(GuWord),