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

Side by Side Diff: src/sksl/SkSLParser.cpp

Issue 2442063002: Reduced skslc memory consumption (Closed)
Patch Set: improved error reporting Created 4 years, 2 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 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "stdio.h" 8 #include "stdio.h"
9 #include "SkSLParser.h" 9 #include "SkSLParser.h"
10 #include "SkSLToken.h" 10 #include "SkSLToken.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 } 125 }
126 126
127 Token Parser::nextToken() { 127 Token Parser::nextToken() {
128 if (fPushback.fKind != Token::INVALID_TOKEN) { 128 if (fPushback.fKind != Token::INVALID_TOKEN) {
129 Token result = fPushback; 129 Token result = fPushback;
130 fPushback.fKind = Token::INVALID_TOKEN; 130 fPushback.fKind = Token::INVALID_TOKEN;
131 fPushback.fText = ""; 131 fPushback.fText = "";
132 return result; 132 return result;
133 } 133 }
134 int token = sksllex(fScanner); 134 int token = sksllex(fScanner);
135 return Token(Position(skslget_lineno(fScanner), -1), (Token::Kind) token, 135 std::string text;
136 token == Token::END_OF_FILE ? "<end of file>" : 136 switch ((Token::Kind) token) {
137 std::string(skslget_text(fScanner ))); 137 case Token::IDENTIFIER: // fall through
138 case Token::INT_LITERAL: // fall through
139 case Token::FLOAT_LITERAL: // fall through
140 case Token::DIRECTIVE:
141 text = std::string(skslget_text(fScanner));
142 break;
143 default:
144 break;
145 }
146 return Token(Position(skslget_lineno(fScanner), -1), (Token::Kind) token, te xt);
138 } 147 }
139 148
140 void Parser::pushback(Token t) { 149 void Parser::pushback(Token t) {
141 ASSERT(fPushback.fKind == Token::INVALID_TOKEN); 150 ASSERT(fPushback.fKind == Token::INVALID_TOKEN);
142 fPushback = t; 151 fPushback = t;
143 } 152 }
144 153
145 Token Parser::peek() { 154 Token Parser::peek() {
146 fPushback = this->nextToken(); 155 fPushback = this->nextToken();
147 return fPushback; 156 return fPushback;
(...skipping 1297 matching lines...) Expand 10 before | Expand all | Expand 10 after
1445 bool Parser::identifier(std::string* dest) { 1454 bool Parser::identifier(std::string* dest) {
1446 Token t; 1455 Token t;
1447 if (this->expect(Token::IDENTIFIER, "identifier", &t)) { 1456 if (this->expect(Token::IDENTIFIER, "identifier", &t)) {
1448 *dest = t.fText; 1457 *dest = t.fText;
1449 return true; 1458 return true;
1450 } 1459 }
1451 return false; 1460 return false;
1452 } 1461 }
1453 1462
1454 } // namespace 1463 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698