summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@colm.net>2016-08-23 10:44:14 -0400
committerAdrian Thurston <thurston@colm.net>2016-08-23 10:45:18 -0400
commitcb778b42f4859ca464ad56ecb60ad7ee01f51df0 (patch)
tree08438872ee0130d61e5f10164423f48a200dfa68
parent8e24b1816296f2897001fc3f699e067135222f99 (diff)
downloadcolm-cb778b42f4859ca464ad56ecb60ad7ee01f51df0.tar.gz
added colm_error for extracting the error string
-rw-r--r--src/colm.h2
-rw-r--r--src/program.c11
2 files changed, 13 insertions, 0 deletions
diff --git a/src/colm.h b/src/colm.h
index 0110ef2d..4dd53656 100644
--- a/src/colm.h
+++ b/src/colm.h
@@ -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;