Better error for doc_comment at the end of block.

Previous error:
ERROR: syntax error, unexpected '}' at ...

New error:
ERROR: Doc comments must preceed what they describe at ...

Bug: 78135149
Test: hidl_error_test
Merged-In: Id56e34a4beb33b0323eb86a85190be63ec3b135d
Change-Id: Id56e34a4beb33b0323eb86a85190be63ec3b135d
diff --git a/hidl-gen_y.yy b/hidl-gen_y.yy
index da45823..f445199 100644
--- a/hidl-gen_y.yy
+++ b/hidl-gen_y.yy
@@ -338,6 +338,11 @@
         $1->merge($2);
         $$ = $1;
       }
+    | doc_comments '}'
+      {
+        std::cerr << "ERROR: Doc comments must preceed what they describe at " << @1 << "\n";
+        YYERROR;
+      }
     ;
 
 valid_identifier
diff --git a/test/error_test/doc_comment_ends_block/1.0/IFoo.hal b/test/error_test/doc_comment_ends_block/1.0/IFoo.hal
new file mode 100644
index 0000000..26c768e
--- /dev/null
+++ b/test/error_test/doc_comment_ends_block/1.0/IFoo.hal
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package test.empty_generates@1.0;
+
+interface IFoo {
+    doFoo();
+    /**
+     * Does foo!
+     */
+};
diff --git a/test/error_test/doc_comment_ends_block/1.0/required_error b/test/error_test/doc_comment_ends_block/1.0/required_error
new file mode 100644
index 0000000..94c947a
--- /dev/null
+++ b/test/error_test/doc_comment_ends_block/1.0/required_error
@@ -0,0 +1 @@
+Doc comments must preceed what they describe at
\ No newline at end of file