diff options
Diffstat (limited to 'src/google/protobuf/compiler/parser.h')
-rw-r--r-- | src/google/protobuf/compiler/parser.h | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/src/google/protobuf/compiler/parser.h b/src/google/protobuf/compiler/parser.h index 0f80e78b..5d98e5e1 100644 --- a/src/google/protobuf/compiler/parser.h +++ b/src/google/protobuf/compiler/parser.h @@ -40,10 +40,10 @@ #include <map> #include <string> #include <utility> -#include <google/protobuf/descriptor.h> #include <google/protobuf/descriptor.pb.h> -#include <google/protobuf/repeated_field.h> #include <google/protobuf/io/tokenizer.h> +#include <google/protobuf/descriptor.h> +#include <google/protobuf/repeated_field.h> namespace google { namespace protobuf { class Message; } @@ -224,6 +224,10 @@ class LIBPROTOBUF_EXPORT Parser { LocationRecorder(const LocationRecorder& parent, int path1); LocationRecorder(const LocationRecorder& parent, int path1, int path2); + // Creates a recorder that generates locations into given source code info. + LocationRecorder(const LocationRecorder& parent, int path1, + SourceCodeInfo* source_code_info); + ~LocationRecorder(); // Add a path component. See SourceCodeInfo.Location.path in @@ -250,6 +254,9 @@ class LIBPROTOBUF_EXPORT Parser { void RecordLegacyLocation(const Message* descriptor, DescriptorPool::ErrorCollector::ErrorLocation location); + // Returns the number of path components in the recorder's current location. + int CurrentPathSize() const; + // Attaches leading and trailing comments to the location. The two strings // will be swapped into place, so after this is called *leading and // *trailing will be empty. @@ -257,16 +264,17 @@ class LIBPROTOBUF_EXPORT Parser { // TODO(kenton): See comment on TryConsumeEndOfDeclaration(), above, for // why this is const. void AttachComments(string* leading, string* trailing, - vector<string>* detached_comments) const; + std::vector<string>* detached_comments) const; private: // Indexes of parent and current location in the parent // SourceCodeInfo.location repeated field. For top-level elements, // parent_index_ is -1. Parser* parser_; + SourceCodeInfo* source_code_info_; SourceCodeInfo::Location* location_; - void Init(const LocationRecorder& parent); + void Init(const LocationRecorder& parent, SourceCodeInfo* source_code_info); }; // ================================================================= @@ -371,6 +379,12 @@ class LIBPROTOBUF_EXPORT Parser { const LocationRecorder& parent_location); bool ParseReservedNumbers(DescriptorProto* message, const LocationRecorder& parent_location); + bool ParseReserved(EnumDescriptorProto* message, + const LocationRecorder& message_location); + bool ParseReservedNames(EnumDescriptorProto* message, + const LocationRecorder& parent_location); + bool ParseReservedNumbers(EnumDescriptorProto* message, + const LocationRecorder& parent_location); // Parse an "extend" declaration. (See also comments for // ParseMessageField().) @@ -520,7 +534,7 @@ class LIBPROTOBUF_EXPORT Parser { // detached comments will be put into the leading_detached_comments field for // the next element (See SourceCodeInfo.Location in descriptor.proto), when // ConsumeEndOfDeclaration() is called. - vector<string> upcoming_detached_comments_; + std::vector<string> upcoming_detached_comments_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Parser); }; @@ -556,9 +570,9 @@ class LIBPROTOBUF_EXPORT SourceLocationTable { void Clear(); private: - typedef map< - pair<const Message*, DescriptorPool::ErrorCollector::ErrorLocation>, - pair<int, int> > LocationMap; + typedef std::map< + std::pair<const Message*, DescriptorPool::ErrorCollector::ErrorLocation>, + std::pair<int, int> > LocationMap; LocationMap location_map_; }; |