hidl-gen: some error recovery.
Detect some errors and attempt to recover when a
';' is seen.
Attempt to remind the writer for missing ';'s.
TODO: more error recovery should be done
for hidl/errorhal/error/1.0/IEx1.hal
Bug: 31367057 (partly fixes)
Test: mma
Test: `hidl-gen -Lc++ -r tests.errors:system/tools/hidl/test/errorhal -o
~/temp tests.errors.syntax@1.0`
The output has the correct positions marked for the errors.
Change-Id: I858129e08a10cc12a9978adc7fe0c0b94ffbf83e
diff --git a/AST.h b/AST.h
index 12dfc89..cac5b26 100644
--- a/AST.h
+++ b/AST.h
@@ -104,6 +104,10 @@
void appendToExportedTypesVector(
std::vector<const Type *> *exportedTypes) const;
+ // used by the parser.
+ void addSyntaxError();
+ size_t syntaxErrors() const;
+
private:
Coordinator *mCoordinator;
std::string mPath;
@@ -134,6 +138,9 @@
// Types keyed by full names defined in this AST.
std::map<FQName, Type *> mDefinedTypesByFullName;
+ // used by the parser.
+ size_t mSyntaxErrors = 0;
+
bool addScopedTypeInternal(
NamedType *type,
std::string *errorMsg);