better error-handling, importing entire packages. Cache now keyed by FQName
diff --git a/hidl-gen_l.ll b/hidl-gen_l.ll
index 67239a4..fe95c3f 100644
--- a/hidl-gen_l.ll
+++ b/hidl-gen_l.ll
@@ -148,20 +148,29 @@
ECHO;
}
-void parseFile(AST *ast, const char *path) {
+status_t parseFile(AST *ast, const char *path) {
FILE *file = fopen(path, "rb");
+ if (file == NULL) {
+ return -errno;
+ }
+
yyscan_t scanner;
yylex_init_extra(ast, &scanner);
ast->setScanner(scanner);
yyset_in(file, scanner);
int res = yyparse(ast);
- assert(res == 0);
yylex_destroy(scanner);
ast->setScanner(NULL);
fclose(file);
file = NULL;
+
+ if (res != 0) {
+ return UNKNOWN_ERROR;
+ }
+
+ return OK;
}