summaryrefslogtreecommitdiffstats
path: root/dimension
diff options
context:
space:
mode:
Diffstat (limited to 'dimension')
-rw-r--r--dimension/grammar.epilogue2
-rw-r--r--dimension/tokenize.c12
-rw-r--r--dimension/tokenize.h1
3 files changed, 15 insertions, 0 deletions
diff --git a/dimension/grammar.epilogue b/dimension/grammar.epilogue
index ecb910a..6ea4e28 100644
--- a/dimension/grammar.epilogue
+++ b/dimension/grammar.epilogue
@@ -43,6 +43,7 @@ dmnsn_parse(FILE *file, dmnsn_symbol_table *symtable)
astree = NULL;
}
+ dmnsn_yylex_cleanup(scanner);
dmnsn_yylex_destroy(scanner);
return astree;
}
@@ -73,6 +74,7 @@ dmnsn_parse_string(const char *str, dmnsn_symbol_table *symtable)
astree = NULL;
}
+ dmnsn_yylex_cleanup(scanner);
dmnsn_yylex_destroy(scanner);
return astree;
}
diff --git a/dimension/tokenize.c b/dimension/tokenize.c
index 8d85b2d..7269fb4 100644
--- a/dimension/tokenize.c
+++ b/dimension/tokenize.c
@@ -788,3 +788,15 @@ dmnsn_yylex(dmnsn_parse_item *lvalp, dmnsn_parse_location *llocp,
}
}
}
+
+void
+dmnsn_yylex_cleanup(void *yyscanner)
+{
+ dmnsn_token_buffer *tbuffer = dmnsn_yyget_extra(yyscanner);
+ while (tbuffer) {
+ dmnsn_token_buffer *prev = tbuffer->prev;
+ dmnsn_delete_token_buffer(tbuffer);
+ tbuffer = prev;
+ }
+ dmnsn_yyset_extra(NULL, yyscanner);
+}
diff --git a/dimension/tokenize.h b/dimension/tokenize.h
index 86be4c9..86ee5d1 100644
--- a/dimension/tokenize.h
+++ b/dimension/tokenize.h
@@ -63,6 +63,7 @@ void dmnsn_yy_pop_buffer(void *scanner);
int dmnsn_yylex(dmnsn_parse_item *lvalp, dmnsn_parse_location *llocp,
const char *filename, dmnsn_symbol_table *symtable,
void *yyscanner);
+void dmnsn_yylex_cleanup(void *yyscanner);
/* For debugging - returns an array of raw tokens */
dmnsn_array *dmnsn_tokenize(FILE *file, const char *filename);