Preprocessed uses the same syntax of AIDL

Preprocessed file has been using a similar but different syntax.  Now,
it is using the same syntax with AIDL files with a couple of small
changes.

- Type decl can have qualified name.
  (interestinly, I only changed this for interface/enum)
- Interface can omit body(members) blocks.
  interface IFoo; // is simply an empty interface

Bug: 25479378
Test: aidl_unittests
Test: m
Change-Id: Icf5e4c321c469af00506c5ff14782251018d9d57
diff --git a/parser.h b/parser.h
index 67668a0..f286de2 100644
--- a/parser.h
+++ b/parser.h
@@ -68,7 +68,7 @@
   // Parse contents of file |filename|. Should only be called once.
   static const AidlDocument* Parse(const std::string& filename,
                                    const android::aidl::IoDelegate& io_delegate,
-                                   AidlTypenames& typenames);
+                                   AidlTypenames& typenames, bool is_preprocessed = false);
 
   void AddError() { error_++; }
   bool HasError() const { return error_ != 0; }
@@ -85,30 +85,23 @@
   void SetTypeParameters(AidlTypeSpecifier* type,
                          std::vector<std::unique_ptr<AidlTypeSpecifier>>* type_args);
 
-  void SetPackage(const std::string& package) { package_ = package; }
+  // fully-qualified type names are allowed only in preprocessed files
+  void CheckValidTypeName(const AidlToken& token, const AidlLocation& loc);
+
+  void SetPackage(const AidlPackage& package);
   const std::string& Package() const { return package_; }
 
-  void SetDocument(std::unique_ptr<AidlDocument>&& document) {
-    // The parsed document is owned by typenames_. This parser object only has
-    // a reference to it.
-    document_ = document.get();
-    if (!typenames_.AddDocument(std::move(document))) {
-      document_ = nullptr;
-      AddError();
-    }
-  }
+  void SetDocument(std::unique_ptr<AidlDocument> document) { document_ = std::move(document); }
 
  private:
-  explicit Parser(const std::string& filename, std::string& raw_buffer,
-                  android::aidl::AidlTypenames& typenames);
+  explicit Parser(const std::string& filename, std::string& raw_buffer, bool is_preprocessed);
 
   std::string filename_;
+  bool is_preprocessed_;
   std::string package_;
-  AidlTypenames& typenames_;
-
   void* scanner_ = nullptr;
   YY_BUFFER_STATE buffer_;
   int error_ = 0;
 
-  const AidlDocument* document_;
+  std::unique_ptr<AidlDocument> document_;
 };