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

Side by Side Diff: base/test/expectations/parser.cc

Issue 1641513004: Update //base to chromium 9659b08ea5a34f889dc4166217f438095ddc10d2 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 10 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 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/test/expectations/parser.h" 5 #include "base/test/expectations/parser.h"
6 6
7 #include "base/strings/string_util.h" 7 #include "base/strings/string_util.h"
8 8
9 namespace test_expectations { 9 namespace test_expectations {
10 10
(...skipping 21 matching lines...) Expand all
32 } 32 }
33 } 33 }
34 34
35 inline bool Parser::HasNext() { 35 inline bool Parser::HasNext() {
36 return pos_ < end_; 36 return pos_ < end_;
37 } 37 }
38 38
39 Parser::StateFunc Parser::Start() { 39 Parser::StateFunc Parser::Start() {
40 // If at the start of a line is whitespace, skip it and arrange to come back 40 // If at the start of a line is whitespace, skip it and arrange to come back
41 // here. 41 // here.
42 if (IsAsciiWhitespace(*pos_)) 42 if (base::IsAsciiWhitespace(*pos_))
43 return SkipWhitespaceAndNewLines(&Parser::Start); 43 return SkipWhitespaceAndNewLines(&Parser::Start);
44 44
45 // Handle comments at the start of lines. 45 // Handle comments at the start of lines.
46 if (*pos_ == '#') 46 if (*pos_ == '#')
47 return &Parser::ParseComment; 47 return &Parser::ParseComment;
48 48
49 // After arranging to come back here from skipping whitespace and comments, 49 // After arranging to come back here from skipping whitespace and comments,
50 // the parser may be at the end of the input. 50 // the parser may be at the end of the input.
51 if (pos_ >= end_) 51 if (pos_ >= end_)
52 return NULL; 52 return NULL;
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 delegate_->EmitExpectation(current_); 154 delegate_->EmitExpectation(current_);
155 155
156 if (HasNext()) 156 if (HasNext())
157 return SkipWhitespaceAndNewLines(&Parser::Start); 157 return SkipWhitespaceAndNewLines(&Parser::Start);
158 158
159 return NULL; 159 return NULL;
160 } 160 }
161 161
162 Parser::StateFunc Parser::ExtractString(StateFunc success) { 162 Parser::StateFunc Parser::ExtractString(StateFunc success) {
163 const char* start = pos_; 163 const char* start = pos_;
164 while (!IsAsciiWhitespace(*pos_) && *pos_ != ']' && HasNext()) { 164 while (!base::IsAsciiWhitespace(*pos_) && *pos_ != ']' && HasNext()) {
165 ++pos_; 165 ++pos_;
166 if (*pos_ == '#') { 166 if (*pos_ == '#') {
167 return SyntaxError("Unexpected start of comment"); 167 return SyntaxError("Unexpected start of comment");
168 } 168 }
169 } 169 }
170 extracted_string_ = base::StringPiece(start, pos_ - start); 170 extracted_string_ = base::StringPiece(start, pos_ - start);
171 return success; 171 return success;
172 } 172 }
173 173
174 Parser::StateFunc Parser::SkipWhitespace(Parser::StateFunc next) { 174 Parser::StateFunc Parser::SkipWhitespace(Parser::StateFunc next) {
175 while ((*pos_ == ' ' || *pos_ == '\t') && HasNext()) { 175 while ((*pos_ == ' ' || *pos_ == '\t') && HasNext()) {
176 ++pos_; 176 ++pos_;
177 } 177 }
178 return next; 178 return next;
179 } 179 }
180 180
181 Parser::StateFunc Parser::SkipWhitespaceAndNewLines(Parser::StateFunc next) { 181 Parser::StateFunc Parser::SkipWhitespaceAndNewLines(Parser::StateFunc next) {
182 while (IsAsciiWhitespace(*pos_) && HasNext()) { 182 while (base::IsAsciiWhitespace(*pos_) && HasNext()) {
183 if (*pos_ == '\n') { 183 if (*pos_ == '\n') {
184 ++line_number_; 184 ++line_number_;
185 } 185 }
186 ++pos_; 186 ++pos_;
187 } 187 }
188 return next; 188 return next;
189 } 189 }
190 190
191 Parser::StateFunc Parser::SyntaxError(const std::string& message) { 191 Parser::StateFunc Parser::SyntaxError(const std::string& message) {
192 delegate_->OnSyntaxError(message); 192 delegate_->OnSyntaxError(message);
193 return NULL; 193 return NULL;
194 } 194 }
195 195
196 void Parser::DataError(const std::string& error) { 196 void Parser::DataError(const std::string& error) {
197 data_error_ = true; 197 data_error_ = true;
198 delegate_->OnDataError(error); 198 delegate_->OnDataError(error);
199 } 199 }
200 200
201 } // namespace test_expectations 201 } // namespace test_expectations
OLDNEW
« no previous file with comments | « base/test/android/javatests/src/org/chromium/base/test/util/CommandLineFlags.java ('k') | base/test/histogram_tester.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698