Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
project(HAMMER_PARSE C)

file(GLOB_RECURSE APP_SRC_FILES
"src/*.c"
)

# Create the app module
add_cfe_app(hammer_parse ${APP_SRC_FILES})

# The API to this library (which may be invoked/referenced from other apps)
# is stored in fsw/public_inc. Using "target_include_directories" is the
# preferred method of indicating this (vs. directory-scope "include_directories").
target_include_directories(hammer_parse PUBLIC
src/backends
src/parsers
.
src)




4 changes: 2 additions & 2 deletions src/allocator.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,12 +284,12 @@ void *h_arena_realloc(HArena *arena, void *ptr, size_t n) {
// much data from the old block as there could have been.

for (link = arena->head; link; link = link->next) {
if (ptr >= (void *)link->rest && ptr <= (void *)link->rest + link->used)
if ((char *)ptr >= (char *)link->rest && (char *)ptr <= (char *)link->rest + link->used)
break; /* found it */
}
assert(link != NULL);

ncopy = (void *)link->rest + link->used - ptr;
ncopy = ((char *)link->rest + link->used) - (char *)ptr;
if (n < ncopy)
ncopy = n;

Expand Down
2 changes: 1 addition & 1 deletion src/backends/packrat.c
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ bool h_packrat_parse_chunk(HSuspendedParser *s, HInputStream *input) {
h_platform_errx(1, "input length would overflow");
newlen = cat->length + input->length;
cat->input = h_realloc(mm__, (void *)cat->input, newlen);
memcpy((void *)cat->input + cat->length, input->input, input->length);
memcpy((char *)cat->input + cat->length, input->input, input->length);
cat->length = newlen;
cat->last_chunk = input->last_chunk;

Expand Down
2 changes: 1 addition & 1 deletion src/hammer.c
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ HParsedToken *act_backend_params(const HParseResult *p, void *user_data) {

backend_params_t *bp = H_ALLOC(backend_params_t);

HParsedToken **fields = h_seq_elements(p->ast);
//HParsedToken **fields = h_seq_elements(p->ast);

bp->len = h_seq_len(p->ast);
bp->params = h_arena_malloc(p->arena, sizeof(backend_param_with_name_t) * bp->len);
Expand Down
2 changes: 1 addition & 1 deletion src/hammer.h
Original file line number Diff line number Diff line change
Expand Up @@ -1239,7 +1239,7 @@ struct result_buf;

bool h_append_buf(struct result_buf *buf, const char *input, int len);
bool h_append_buf_c(struct result_buf *buf, char v);
bool h_append_buf_formatted(struct result_buf *buf, char *format, ...);
bool h_append_buf_formatted(struct result_buf *buf, const char *format, ...);

/** @} */

Expand Down
2 changes: 1 addition & 1 deletion src/parsers/unimplemented.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ static const HParserVtable unimplemented_vt = {

static HParser unimplemented = {.vtable = &unimplemented_vt, .env = NULL};

const HParser *h_unimplemented() { return &unimplemented; }
const HParser *h_unimplemented(void) { return &unimplemented; }
const HParser *h_unimplemented__m(HAllocator *mm__) { return &unimplemented; }
2 changes: 1 addition & 1 deletion src/pprint.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ bool h_append_buf_c(struct result_buf *buf, char v) {
}

/** append a formatted string to the result buffer */
bool h_append_buf_formatted(struct result_buf *buf, char *format, ...) {
bool h_append_buf_formatted(struct result_buf *buf, const char *format, ...) {
char *tmpbuf;
int len;
bool result;
Expand Down
2 changes: 1 addition & 1 deletion src/sloballoc.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ static void h_slob_free(HAllocator *mm, void *p) {
}

static void *h_slob_realloc(HAllocator *mm, void *p, size_t size) {
SLOB *slob = (SLOB *)(mm + 1);
//SLOB *slob = (SLOB *)(mm + 1);

assert(((void)"XXX need realloc for SLOB allocator", 0));
return NULL;
Expand Down