Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Side by Side Diff: third_party/protobuf/src/google/protobuf/compiler/parser.h

Issue 1842653006: Update //third_party/protobuf to version 3. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Protocol Buffers - Google's data interchange format 1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc. All rights reserved. 2 // Copyright 2008 Google Inc. All rights reserved.
3 // http://code.google.com/p/protobuf/ 3 // https://developers.google.com/protocol-buffers/
4 // 4 //
5 // Redistribution and use in source and binary forms, with or without 5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are 6 // modification, are permitted provided that the following conditions are
7 // met: 7 // met:
8 // 8 //
9 // * Redistributions of source code must retain the above copyright 9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer. 10 // notice, this list of conditions and the following disclaimer.
11 // * Redistributions in binary form must reproduce the above 11 // * Redistributions in binary form must reproduce the above
12 // copyright notice, this list of conditions and the following disclaimer 12 // copyright notice, this list of conditions and the following disclaimer
13 // in the documentation and/or other materials provided with the 13 // in the documentation and/or other materials provided with the
(...skipping 19 matching lines...) Expand all
33 // Sanjay Ghemawat, Jeff Dean, and others. 33 // Sanjay Ghemawat, Jeff Dean, and others.
34 // 34 //
35 // Implements parsing of .proto files to FileDescriptorProtos. 35 // Implements parsing of .proto files to FileDescriptorProtos.
36 36
37 #ifndef GOOGLE_PROTOBUF_COMPILER_PARSER_H__ 37 #ifndef GOOGLE_PROTOBUF_COMPILER_PARSER_H__
38 #define GOOGLE_PROTOBUF_COMPILER_PARSER_H__ 38 #define GOOGLE_PROTOBUF_COMPILER_PARSER_H__
39 39
40 #include <map> 40 #include <map>
41 #include <string> 41 #include <string>
42 #include <utility> 42 #include <utility>
43 #include <google/protobuf/stubs/common.h>
44 #include <google/protobuf/descriptor.h> 43 #include <google/protobuf/descriptor.h>
45 #include <google/protobuf/descriptor.pb.h> 44 #include <google/protobuf/descriptor.pb.h>
46 #include <google/protobuf/repeated_field.h> 45 #include <google/protobuf/repeated_field.h>
47 #include <google/protobuf/io/tokenizer.h> 46 #include <google/protobuf/io/tokenizer.h>
48 47
49 namespace google { 48 namespace google {
50 namespace protobuf { class Message; } 49 namespace protobuf { class Message; }
51 50
52 namespace protobuf { 51 namespace protobuf {
53 namespace compiler { 52 namespace compiler {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 178
180 // Consume a token representing the end of the statement. Comments between 179 // Consume a token representing the end of the statement. Comments between
181 // this token and the next will be harvested for documentation. The given 180 // this token and the next will be harvested for documentation. The given
182 // LocationRecorder should refer to the declaration that was just parsed; 181 // LocationRecorder should refer to the declaration that was just parsed;
183 // it will be populated with these comments. 182 // it will be populated with these comments.
184 // 183 //
185 // TODO(kenton): The LocationRecorder is const because historically locations 184 // TODO(kenton): The LocationRecorder is const because historically locations
186 // have been passed around by const reference, for no particularly good 185 // have been passed around by const reference, for no particularly good
187 // reason. We should probably go through and change them all to mutable 186 // reason. We should probably go through and change them all to mutable
188 // pointer to make this more intuitive. 187 // pointer to make this more intuitive.
189 bool TryConsumeEndOfDeclaration(const char* text, 188 bool TryConsumeEndOfDeclaration(
190 const LocationRecorder* location); 189 const char* text, const LocationRecorder* location);
191 bool ConsumeEndOfDeclaration(const char* text, 190 bool TryConsumeEndOfDeclarationFinishScope(
192 const LocationRecorder* location); 191 const char* text, const LocationRecorder* location);
192
193 bool ConsumeEndOfDeclaration(
194 const char* text, const LocationRecorder* location);
193 195
194 // ----------------------------------------------------------------- 196 // -----------------------------------------------------------------
195 // Error logging helpers 197 // Error logging helpers
196 198
197 // Invokes error_collector_->AddError(), if error_collector_ is not NULL. 199 // Invokes error_collector_->AddError(), if error_collector_ is not NULL.
198 void AddError(int line, int column, const string& error); 200 void AddError(int line, int column, const string& error);
199 201
200 // Invokes error_collector_->AddError() with the line and column number 202 // Invokes error_collector_->AddError() with the line and column number
201 // of the current token. 203 // of the current token.
202 void AddError(const string& error); 204 void AddError(const string& error);
(...skipping 23 matching lines...) Expand all
226 228
227 // Add a path component. See SourceCodeInfo.Location.path in 229 // Add a path component. See SourceCodeInfo.Location.path in
228 // descriptor.proto. 230 // descriptor.proto.
229 void AddPath(int path_component); 231 void AddPath(int path_component);
230 232
231 // By default the location is considered to start at the current token at 233 // By default the location is considered to start at the current token at
232 // the time the LocationRecorder is created. StartAt() sets the start 234 // the time the LocationRecorder is created. StartAt() sets the start
233 // location to the given token instead. 235 // location to the given token instead.
234 void StartAt(const io::Tokenizer::Token& token); 236 void StartAt(const io::Tokenizer::Token& token);
235 237
238 // Start at the same location as some other LocationRecorder.
239 void StartAt(const LocationRecorder& other);
240
236 // By default the location is considered to end at the previous token at 241 // By default the location is considered to end at the previous token at
237 // the time the LocationRecorder is destroyed. EndAt() sets the end 242 // the time the LocationRecorder is destroyed. EndAt() sets the end
238 // location to the given token instead. 243 // location to the given token instead.
239 void EndAt(const io::Tokenizer::Token& token); 244 void EndAt(const io::Tokenizer::Token& token);
240 245
241 // Records the start point of this location to the SourceLocationTable that 246 // Records the start point of this location to the SourceLocationTable that
242 // was passed to RecordSourceLocationsTo(), if any. SourceLocationTable 247 // was passed to RecordSourceLocationsTo(), if any. SourceLocationTable
243 // is an older way of keeping track of source locations which is still 248 // is an older way of keeping track of source locations which is still
244 // used in some places. 249 // used in some places.
245 void RecordLegacyLocation(const Message* descriptor, 250 void RecordLegacyLocation(const Message* descriptor,
246 DescriptorPool::ErrorCollector::ErrorLocation location); 251 DescriptorPool::ErrorCollector::ErrorLocation location);
247 252
248 // Attaches leading and trailing comments to the location. The two strings 253 // Attaches leading and trailing comments to the location. The two strings
249 // will be swapped into place, so after this is called *leading and 254 // will be swapped into place, so after this is called *leading and
250 // *trailing will be empty. 255 // *trailing will be empty.
251 // 256 //
252 // TODO(kenton): See comment on TryConsumeEndOfDeclaration(), above, for 257 // TODO(kenton): See comment on TryConsumeEndOfDeclaration(), above, for
253 // why this is const. 258 // why this is const.
254 void AttachComments(string* leading, string* trailing) const; 259 void AttachComments(string* leading, string* trailing,
260 vector<string>* detached_comments) const;
255 261
256 private: 262 private:
263 // Indexes of parent and current location in the parent
264 // SourceCodeInfo.location repeated field. For top-level elements,
265 // parent_index_ is -1.
257 Parser* parser_; 266 Parser* parser_;
258 SourceCodeInfo::Location* location_; 267 SourceCodeInfo::Location* location_;
259 268
260 void Init(const LocationRecorder& parent); 269 void Init(const LocationRecorder& parent);
261 }; 270 };
262 271
263 // ================================================================= 272 // =================================================================
264 // Parsers for various language constructs 273 // Parsers for various language constructs
265 274
266 // Parses the "syntax = \"proto2\";" line at the top of the file. Returns 275 // Parses the "syntax = \"proto2\";" line at the top of the file. Returns
267 // false if it failed to parse or if the syntax identifier was not 276 // false if it failed to parse or if the syntax identifier was not
268 // recognized. 277 // recognized.
269 bool ParseSyntaxIdentifier(); 278 bool ParseSyntaxIdentifier(const LocationRecorder& parent);
270 279
271 // These methods parse various individual bits of code. They return 280 // These methods parse various individual bits of code. They return
272 // false if they completely fail to parse the construct. In this case, 281 // false if they completely fail to parse the construct. In this case,
273 // it is probably necessary to skip the rest of the statement to recover. 282 // it is probably necessary to skip the rest of the statement to recover.
274 // However, if these methods return true, it does NOT mean that there 283 // However, if these methods return true, it does NOT mean that there
275 // were no errors; only that there were no *syntax* errors. For instance, 284 // were no errors; only that there were no *syntax* errors. For instance,
276 // if a service method is defined using proper syntax but uses a primitive 285 // if a service method is defined using proper syntax but uses a primitive
277 // type as its input or output, ParseMethodField() still returns true 286 // type as its input or output, ParseMethodField() still returns true
278 // and only reports the error by calling AddError(). In practice, this 287 // and only reports the error by calling AddError(). In practice, this
279 // makes logic much simpler for the caller. 288 // makes logic much simpler for the caller.
280 289
281 // Parse a top-level message, enum, service, etc. 290 // Parse a top-level message, enum, service, etc.
282 bool ParseTopLevelStatement(FileDescriptorProto* file, 291 bool ParseTopLevelStatement(FileDescriptorProto* file,
283 const LocationRecorder& root_location); 292 const LocationRecorder& root_location);
284 293
285 // Parse various language high-level language construrcts. 294 // Parse various language high-level language construrcts.
286 bool ParseMessageDefinition(DescriptorProto* message, 295 bool ParseMessageDefinition(DescriptorProto* message,
287 const LocationRecorder& message_location); 296 const LocationRecorder& message_location,
297 const FileDescriptorProto* containing_file);
288 bool ParseEnumDefinition(EnumDescriptorProto* enum_type, 298 bool ParseEnumDefinition(EnumDescriptorProto* enum_type,
289 const LocationRecorder& enum_location); 299 const LocationRecorder& enum_location,
300 const FileDescriptorProto* containing_file);
290 bool ParseServiceDefinition(ServiceDescriptorProto* service, 301 bool ParseServiceDefinition(ServiceDescriptorProto* service,
291 const LocationRecorder& service_location); 302 const LocationRecorder& service_location,
303 const FileDescriptorProto* containing_file);
292 bool ParsePackage(FileDescriptorProto* file, 304 bool ParsePackage(FileDescriptorProto* file,
293 const LocationRecorder& root_location); 305 const LocationRecorder& root_location,
306 const FileDescriptorProto* containing_file);
294 bool ParseImport(RepeatedPtrField<string>* dependency, 307 bool ParseImport(RepeatedPtrField<string>* dependency,
295 RepeatedField<int32>* public_dependency, 308 RepeatedField<int32>* public_dependency,
296 RepeatedField<int32>* weak_dependency, 309 RepeatedField<int32>* weak_dependency,
297 const LocationRecorder& root_location); 310 const LocationRecorder& root_location,
298 bool ParseOption(Message* options, 311 const FileDescriptorProto* containing_file);
299 const LocationRecorder& options_location);
300 312
301 // These methods parse the contents of a message, enum, or service type and 313 // These methods parse the contents of a message, enum, or service type and
302 // add them to the given object. They consume the entire block including 314 // add them to the given object. They consume the entire block including
303 // the beginning and ending brace. 315 // the beginning and ending brace.
304 bool ParseMessageBlock(DescriptorProto* message, 316 bool ParseMessageBlock(DescriptorProto* message,
305 const LocationRecorder& message_location); 317 const LocationRecorder& message_location,
318 const FileDescriptorProto* containing_file);
306 bool ParseEnumBlock(EnumDescriptorProto* enum_type, 319 bool ParseEnumBlock(EnumDescriptorProto* enum_type,
307 const LocationRecorder& enum_location); 320 const LocationRecorder& enum_location,
321 const FileDescriptorProto* containing_file);
308 bool ParseServiceBlock(ServiceDescriptorProto* service, 322 bool ParseServiceBlock(ServiceDescriptorProto* service,
309 const LocationRecorder& service_location); 323 const LocationRecorder& service_location,
324 const FileDescriptorProto* containing_file);
310 325
311 // Parse one statement within a message, enum, or service block, inclunding 326 // Parse one statement within a message, enum, or service block, including
312 // final semicolon. 327 // final semicolon.
313 bool ParseMessageStatement(DescriptorProto* message, 328 bool ParseMessageStatement(DescriptorProto* message,
314 const LocationRecorder& message_location); 329 const LocationRecorder& message_location,
330 const FileDescriptorProto* containing_file);
315 bool ParseEnumStatement(EnumDescriptorProto* message, 331 bool ParseEnumStatement(EnumDescriptorProto* message,
316 const LocationRecorder& enum_location); 332 const LocationRecorder& enum_location,
333 const FileDescriptorProto* containing_file);
317 bool ParseServiceStatement(ServiceDescriptorProto* message, 334 bool ParseServiceStatement(ServiceDescriptorProto* message,
318 const LocationRecorder& service_location); 335 const LocationRecorder& service_location,
336 const FileDescriptorProto* containing_file);
319 337
320 // Parse a field of a message. If the field is a group, its type will be 338 // Parse a field of a message. If the field is a group, its type will be
321 // added to "messages". 339 // added to "messages".
322 // 340 //
323 // parent_location and location_field_number_for_nested_type are needed when 341 // parent_location and location_field_number_for_nested_type are needed when
324 // parsing groups -- we need to generate a nested message type within the 342 // parsing groups -- we need to generate a nested message type within the
325 // parent and record its location accordingly. Since the parent could be 343 // parent and record its location accordingly. Since the parent could be
326 // either a FileDescriptorProto or a DescriptorProto, we must pass in the 344 // either a FileDescriptorProto or a DescriptorProto, we must pass in the
327 // correct field number to use. 345 // correct field number to use.
328 bool ParseMessageField(FieldDescriptorProto* field, 346 bool ParseMessageField(FieldDescriptorProto* field,
329 RepeatedPtrField<DescriptorProto>* messages, 347 RepeatedPtrField<DescriptorProto>* messages,
330 const LocationRecorder& parent_location, 348 const LocationRecorder& parent_location,
331 int location_field_number_for_nested_type, 349 int location_field_number_for_nested_type,
332 const LocationRecorder& field_location); 350 const LocationRecorder& field_location,
351 const FileDescriptorProto* containing_file);
352
353 // Like ParseMessageField() but expects the label has already been filled in
354 // by the caller.
355 bool ParseMessageFieldNoLabel(FieldDescriptorProto* field,
356 RepeatedPtrField<DescriptorProto>* messages,
357 const LocationRecorder& parent_location,
358 int location_field_number_for_nested_type,
359 const LocationRecorder& field_location,
360 const FileDescriptorProto* containing_file);
333 361
334 // Parse an "extensions" declaration. 362 // Parse an "extensions" declaration.
335 bool ParseExtensions(DescriptorProto* message, 363 bool ParseExtensions(DescriptorProto* message,
336 const LocationRecorder& extensions_location); 364 const LocationRecorder& extensions_location,
365 const FileDescriptorProto* containing_file);
366
367 // Parse a "reserved" declaration.
368 bool ParseReserved(DescriptorProto* message,
369 const LocationRecorder& message_location);
370 bool ParseReservedNames(DescriptorProto* message,
371 const LocationRecorder& parent_location);
372 bool ParseReservedNumbers(DescriptorProto* message,
373 const LocationRecorder& parent_location);
337 374
338 // Parse an "extend" declaration. (See also comments for 375 // Parse an "extend" declaration. (See also comments for
339 // ParseMessageField().) 376 // ParseMessageField().)
340 bool ParseExtend(RepeatedPtrField<FieldDescriptorProto>* extensions, 377 bool ParseExtend(RepeatedPtrField<FieldDescriptorProto>* extensions,
341 RepeatedPtrField<DescriptorProto>* messages, 378 RepeatedPtrField<DescriptorProto>* messages,
342 const LocationRecorder& parent_location, 379 const LocationRecorder& parent_location,
343 int location_field_number_for_nested_type, 380 int location_field_number_for_nested_type,
344 const LocationRecorder& extend_location); 381 const LocationRecorder& extend_location,
382 const FileDescriptorProto* containing_file);
383
384 // Parse a "oneof" declaration. The caller is responsible for setting
385 // oneof_decl->label() since it will have had to parse the label before it
386 // knew it was parsing a oneof.
387 bool ParseOneof(OneofDescriptorProto* oneof_decl,
388 DescriptorProto* containing_type,
389 int oneof_index,
390 const LocationRecorder& oneof_location,
391 const LocationRecorder& containing_type_location,
392 const FileDescriptorProto* containing_file);
345 393
346 // Parse a single enum value within an enum block. 394 // Parse a single enum value within an enum block.
347 bool ParseEnumConstant(EnumValueDescriptorProto* enum_value, 395 bool ParseEnumConstant(EnumValueDescriptorProto* enum_value,
348 const LocationRecorder& enum_value_location); 396 const LocationRecorder& enum_value_location,
397 const FileDescriptorProto* containing_file);
349 398
350 // Parse enum constant options, i.e. the list in square brackets at the end 399 // Parse enum constant options, i.e. the list in square brackets at the end
351 // of the enum constant value definition. 400 // of the enum constant value definition.
352 bool ParseEnumConstantOptions(EnumValueDescriptorProto* value, 401 bool ParseEnumConstantOptions(EnumValueDescriptorProto* value,
353 const LocationRecorder& enum_value_location); 402 const LocationRecorder& enum_value_location,
403 const FileDescriptorProto* containing_file);
354 404
355 // Parse a single method within a service definition. 405 // Parse a single method within a service definition.
356 bool ParseServiceMethod(MethodDescriptorProto* method, 406 bool ParseServiceMethod(MethodDescriptorProto* method,
357 const LocationRecorder& method_location); 407 const LocationRecorder& method_location,
408 const FileDescriptorProto* containing_file);
358 409
359 410
360 // Parse options of a single method or stream. 411 // Parse options of a single method or stream.
361 bool ParseOptions(const LocationRecorder& parent_location, 412 bool ParseMethodOptions(const LocationRecorder& parent_location,
362 const int optionsFieldNumber, 413 const FileDescriptorProto* containing_file,
363 Message* mutable_options); 414 const int optionsFieldNumber,
415 Message* mutable_options);
364 416
365 // Parse "required", "optional", or "repeated" and fill in "label" 417 // Parse "required", "optional", or "repeated" and fill in "label"
366 // with the value. 418 // with the value. Returns true if such a label is consumed.
367 bool ParseLabel(FieldDescriptorProto::Label* label); 419 bool ParseLabel(FieldDescriptorProto::Label* label,
420 const FileDescriptorProto* containing_file);
368 421
369 // Parse a type name and fill in "type" (if it is a primitive) or 422 // Parse a type name and fill in "type" (if it is a primitive) or
370 // "type_name" (if it is not) with the type parsed. 423 // "type_name" (if it is not) with the type parsed.
371 bool ParseType(FieldDescriptorProto::Type* type, 424 bool ParseType(FieldDescriptorProto::Type* type,
372 string* type_name); 425 string* type_name);
373 // Parse a user-defined type and fill in "type_name" with the name. 426 // Parse a user-defined type and fill in "type_name" with the name.
374 // If a primitive type is named, it is treated as an error. 427 // If a primitive type is named, it is treated as an error.
375 bool ParseUserDefinedType(string* type_name); 428 bool ParseUserDefinedType(string* type_name);
376 429
377 // Parses field options, i.e. the stuff in square brackets at the end 430 // Parses field options, i.e. the stuff in square brackets at the end
378 // of a field definition. Also parses default value. 431 // of a field definition. Also parses default value.
379 bool ParseFieldOptions(FieldDescriptorProto* field, 432 bool ParseFieldOptions(FieldDescriptorProto* field,
380 const LocationRecorder& field_location); 433 const LocationRecorder& field_location,
434 const FileDescriptorProto* containing_file);
381 435
382 // Parse the "default" option. This needs special handling because its 436 // Parse the "default" option. This needs special handling because its
383 // type is the field's type. 437 // type is the field's type.
384 bool ParseDefaultAssignment(FieldDescriptorProto* field, 438 bool ParseDefaultAssignment(FieldDescriptorProto* field,
385 const LocationRecorder& field_location); 439 const LocationRecorder& field_location,
440 const FileDescriptorProto* containing_file);
441
442 bool ParseJsonName(FieldDescriptorProto* field,
443 const LocationRecorder& field_location,
444 const FileDescriptorProto* containing_file);
386 445
387 enum OptionStyle { 446 enum OptionStyle {
388 OPTION_ASSIGNMENT, // just "name = value" 447 OPTION_ASSIGNMENT, // just "name = value"
389 OPTION_STATEMENT // "option name = value;" 448 OPTION_STATEMENT // "option name = value;"
390 }; 449 };
391 450
392 // Parse a single option name/value pair, e.g. "ctype = CORD". The name 451 // Parse a single option name/value pair, e.g. "ctype = CORD". The name
393 // identifies a field of the given Message, and the value of that field 452 // identifies a field of the given Message, and the value of that field
394 // is set to the parsed value. 453 // is set to the parsed value.
395 bool ParseOption(Message* options, 454 bool ParseOption(Message* options,
396 const LocationRecorder& options_location, 455 const LocationRecorder& options_location,
456 const FileDescriptorProto* containing_file,
397 OptionStyle style); 457 OptionStyle style);
398 458
399 // Parses a single part of a multipart option name. A multipart name consists 459 // Parses a single part of a multipart option name. A multipart name consists
400 // of names separated by dots. Each name is either an identifier or a series 460 // of names separated by dots. Each name is either an identifier or a series
401 // of identifiers separated by dots and enclosed in parentheses. E.g., 461 // of identifiers separated by dots and enclosed in parentheses. E.g.,
402 // "foo.(bar.baz).qux". 462 // "foo.(bar.baz).qux".
403 bool ParseOptionNamePart(UninterpretedOption* uninterpreted_option, 463 bool ParseOptionNamePart(UninterpretedOption* uninterpreted_option,
404 const LocationRecorder& part_location); 464 const LocationRecorder& part_location,
465 const FileDescriptorProto* containing_file);
405 466
406 // Parses a string surrounded by balanced braces. Strips off the outer 467 // Parses a string surrounded by balanced braces. Strips off the outer
407 // braces and stores the enclosed string in *value. 468 // braces and stores the enclosed string in *value.
408 // E.g., 469 // E.g.,
409 // { foo } *value gets 'foo' 470 // { foo } *value gets 'foo'
410 // { foo { bar: box } } *value gets 'foo { bar: box }' 471 // { foo { bar: box } } *value gets 'foo { bar: box }'
411 // {} *value gets '' 472 // {} *value gets ''
412 // 473 //
413 // REQUIRES: LookingAt("{") 474 // REQUIRES: LookingAt("{")
414 // When finished successfully, we are looking at the first token past 475 // When finished successfully, we are looking at the first token past
415 // the ending brace. 476 // the ending brace.
416 bool ParseUninterpretedBlock(string* value); 477 bool ParseUninterpretedBlock(string* value);
417 478
479 struct MapField {
480 // Whether the field is a map field.
481 bool is_map_field;
482 // The types of the key and value if they are primitive types.
483 FieldDescriptorProto::Type key_type;
484 FieldDescriptorProto::Type value_type;
485 // Or the type names string if the types are customized types.
486 string key_type_name;
487 string value_type_name;
488
489 MapField() : is_map_field(false) {}
490 };
491 // Desugar the map syntax to generate a nested map entry message.
492 void GenerateMapEntry(const MapField& map_field, FieldDescriptorProto* field,
493 RepeatedPtrField<DescriptorProto>* messages);
494
495 // Whether fields without label default to optional fields.
496 bool DefaultToOptionalFields() const {
497 return syntax_identifier_ == "proto3";
498 }
499
500
501 bool ValidateEnum(const EnumDescriptorProto* proto);
502
418 // ================================================================= 503 // =================================================================
419 504
420 io::Tokenizer* input_; 505 io::Tokenizer* input_;
421 io::ErrorCollector* error_collector_; 506 io::ErrorCollector* error_collector_;
422 SourceCodeInfo* source_code_info_; 507 SourceCodeInfo* source_code_info_;
423 SourceLocationTable* source_location_table_; // legacy 508 SourceLocationTable* source_location_table_; // legacy
424 bool had_errors_; 509 bool had_errors_;
425 bool require_syntax_identifier_; 510 bool require_syntax_identifier_;
426 bool stop_after_syntax_identifier_; 511 bool stop_after_syntax_identifier_;
427 string syntax_identifier_; 512 string syntax_identifier_;
428 513
429 // Leading doc comments for the next declaration. These are not complete 514 // Leading doc comments for the next declaration. These are not complete
430 // yet; use ConsumeEndOfDeclaration() to get the complete comments. 515 // yet; use ConsumeEndOfDeclaration() to get the complete comments.
431 string upcoming_doc_comments_; 516 string upcoming_doc_comments_;
432 517
518 // Detached comments are not connected to any syntax entities. Elements in
519 // this vector are paragraphs of comments separated by empty lines. The
520 // detached comments will be put into the leading_detached_comments field for
521 // the next element (See SourceCodeInfo.Location in descriptor.proto), when
522 // ConsumeEndOfDeclaration() is called.
523 vector<string> upcoming_detached_comments_;
524
433 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Parser); 525 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Parser);
434 }; 526 };
435 527
436 // A table mapping (descriptor, ErrorLocation) pairs -- as reported by 528 // A table mapping (descriptor, ErrorLocation) pairs -- as reported by
437 // DescriptorPool when validating descriptors -- to line and column numbers 529 // DescriptorPool when validating descriptors -- to line and column numbers
438 // within the original source code. 530 // within the original source code.
439 // 531 //
440 // This is semi-obsolete: FileDescriptorProto.source_code_info now contains 532 // This is semi-obsolete: FileDescriptorProto.source_code_info now contains
441 // far more complete information about source locations. However, as of this 533 // far more complete information about source locations. However, as of this
442 // writing you still need to use SourceLocationTable when integrating with 534 // writing you still need to use SourceLocationTable when integrating with
(...skipping 25 matching lines...) Expand all
468 pair<const Message*, DescriptorPool::ErrorCollector::ErrorLocation>, 560 pair<const Message*, DescriptorPool::ErrorCollector::ErrorLocation>,
469 pair<int, int> > LocationMap; 561 pair<int, int> > LocationMap;
470 LocationMap location_map_; 562 LocationMap location_map_;
471 }; 563 };
472 564
473 } // namespace compiler 565 } // namespace compiler
474 } // namespace protobuf 566 } // namespace protobuf
475 567
476 } // namespace google 568 } // namespace google
477 #endif // GOOGLE_PROTOBUF_COMPILER_PARSER_H__ 569 #endif // GOOGLE_PROTOBUF_COMPILER_PARSER_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698