diff options
author | Adrian Thurston <thurston@colm.net> | 2016-08-23 10:44:14 -0400 |
---|---|---|
committer | Adrian Thurston <thurston@colm.net> | 2016-08-23 10:45:18 -0400 |
commit | cb778b42f4859ca464ad56ecb60ad7ee01f51df0 (patch) | |
tree | 08438872ee0130d61e5f10164423f48a200dfa68 | |
parent | 8e24b1816296f2897001fc3f699e067135222f99 (diff) | |
download | colm-cb778b42f4859ca464ad56ecb60ad7ee01f51df0.tar.gz |
added colm_error for extracting the error string
-rw-r--r-- | src/colm.h | 2 | ||||
-rw-r--r-- | src/program.c | 11 |
2 files changed, 13 insertions, 0 deletions
@@ -107,6 +107,8 @@ int colm_delete_program( struct colm_program *prg ); void *colm_get_reduce_ctx( struct colm_program *prg ); void colm_set_reduce_ctx( struct colm_program *prg, void *ctx ); +const char *colm_error( struct colm_program *prg, int *length ); + const char **colm_extract_fns( struct colm_program *prg ); #ifdef __cplusplus diff --git a/src/program.c b/src/program.c index 2949ad81..f3071866 100644 --- a/src/program.c +++ b/src/program.c @@ -248,6 +248,17 @@ const char **colm_extract_fns( struct colm_program *prg ) return fns; } +const char *colm_error( struct colm_program *prg, int *length ) +{ + const char *rtn = 0; + if ( prg->error != 0 ) { + rtn = prg->error->tokdata->data; + if ( length != 0 ) + *length = prg->error->tokdata->length; + } + return rtn; +} + int colm_delete_program( program_t *prg ) { tree_t **sp = prg->stack_root; |