OLD | NEW |
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 // https://developers.google.com/protocol-buffers/ | 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. |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 // // because there are blank lines separating it from both. | 184 // // because there are blank lines separating it from both. |
185 // | 185 // |
186 // optional string corge = 5; | 186 // optional string corge = 5; |
187 // /* Block comment attached | 187 // /* Block comment attached |
188 // * to corge. Leading asterisks | 188 // * to corge. Leading asterisks |
189 // * will be removed. */ | 189 // * will be removed. */ |
190 // /* Block comment attached to | 190 // /* Block comment attached to |
191 // * grault. */ | 191 // * grault. */ |
192 // optional int32 grault = 6; | 192 // optional int32 grault = 6; |
193 bool NextWithComments(string* prev_trailing_comments, | 193 bool NextWithComments(string* prev_trailing_comments, |
194 std::vector<string>* detached_comments, | 194 vector<string>* detached_comments, |
195 string* next_leading_comments); | 195 string* next_leading_comments); |
196 | 196 |
197 // Parse helpers --------------------------------------------------- | 197 // Parse helpers --------------------------------------------------- |
198 | 198 |
199 // Parses a TYPE_FLOAT token. This never fails, so long as the text actually | 199 // Parses a TYPE_FLOAT token. This never fails, so long as the text actually |
200 // comes from a TYPE_FLOAT token parsed by Tokenizer. If it doesn't, the | 200 // comes from a TYPE_FLOAT token parsed by Tokenizer. If it doesn't, the |
201 // result is undefined (possibly an assert failure). | 201 // result is undefined (possibly an assert failure). |
202 static double ParseFloat(const string& text); | 202 static double ParseFloat(const string& text); |
203 | 203 |
204 // Parses a TYPE_STRING token. This never fails, so long as the text actually | 204 // Parses a TYPE_STRING token. This never fails, so long as the text actually |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 // in order to decide what kind of token is being read. | 322 // in order to decide what kind of token is being read. |
323 | 323 |
324 // Read and consume a string, ending when the given delimiter is | 324 // Read and consume a string, ending when the given delimiter is |
325 // consumed. | 325 // consumed. |
326 void ConsumeString(char delimiter); | 326 void ConsumeString(char delimiter); |
327 | 327 |
328 // Read and consume a number, returning TYPE_FLOAT or TYPE_INTEGER | 328 // Read and consume a number, returning TYPE_FLOAT or TYPE_INTEGER |
329 // depending on what was read. This needs to know if the first | 329 // depending on what was read. This needs to know if the first |
330 // character was a zero in order to correctly recognize hex and octal | 330 // character was a zero in order to correctly recognize hex and octal |
331 // numbers. | 331 // numbers. |
332 // It also needs to know if the first character was a . to parse floating | 332 // It also needs to know if the first characted was a . to parse floating |
333 // point correctly. | 333 // point correctly. |
334 TokenType ConsumeNumber(bool started_with_zero, bool started_with_dot); | 334 TokenType ConsumeNumber(bool started_with_zero, bool started_with_dot); |
335 | 335 |
336 // Consume the rest of a line. | 336 // Consume the rest of a line. |
337 void ConsumeLineComment(string* content); | 337 void ConsumeLineComment(string* content); |
338 // Consume until "*/". | 338 // Consume until "*/". |
339 void ConsumeBlockComment(string* content); | 339 void ConsumeBlockComment(string* content); |
340 | 340 |
341 enum NextCommentStatus { | 341 enum NextCommentStatus { |
342 // Started a line comment. | 342 // Started a line comment. |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 inline void Tokenizer::ParseString(const string& text, string* output) { | 402 inline void Tokenizer::ParseString(const string& text, string* output) { |
403 output->clear(); | 403 output->clear(); |
404 ParseStringAppend(text, output); | 404 ParseStringAppend(text, output); |
405 } | 405 } |
406 | 406 |
407 } // namespace io | 407 } // namespace io |
408 } // namespace protobuf | 408 } // namespace protobuf |
409 | 409 |
410 } // namespace google | 410 } // namespace google |
411 #endif // GOOGLE_PROTOBUF_IO_TOKENIZER_H__ | 411 #endif // GOOGLE_PROTOBUF_IO_TOKENIZER_H__ |
OLD | NEW |