| OLD | NEW |
| 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 Loading... |
| 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 std::string text; | 135 return Token(Position(skslget_lineno(fScanner), -1), (Token::Kind) token, |
| 136 switch ((Token::Kind) token) { | 136 token == Token::END_OF_FILE ? "<end of file>" : |
| 137 case Token::IDENTIFIER: // fall through | 137 std::string(skslget_text(fScanner
))); |
| 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); | |
| 147 } | 138 } |
| 148 | 139 |
| 149 void Parser::pushback(Token t) { | 140 void Parser::pushback(Token t) { |
| 150 ASSERT(fPushback.fKind == Token::INVALID_TOKEN); | 141 ASSERT(fPushback.fKind == Token::INVALID_TOKEN); |
| 151 fPushback = t; | 142 fPushback = t; |
| 152 } | 143 } |
| 153 | 144 |
| 154 Token Parser::peek() { | 145 Token Parser::peek() { |
| 155 fPushback = this->nextToken(); | 146 fPushback = this->nextToken(); |
| 156 return fPushback; | 147 return fPushback; |
| (...skipping 1297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1454 bool Parser::identifier(std::string* dest) { | 1445 bool Parser::identifier(std::string* dest) { |
| 1455 Token t; | 1446 Token t; |
| 1456 if (this->expect(Token::IDENTIFIER, "identifier", &t)) { | 1447 if (this->expect(Token::IDENTIFIER, "identifier", &t)) { |
| 1457 *dest = t.fText; | 1448 *dest = t.fText; |
| 1458 return true; | 1449 return true; |
| 1459 } | 1450 } |
| 1460 return false; | 1451 return false; |
| 1461 } | 1452 } |
| 1462 | 1453 |
| 1463 } // namespace | 1454 } // namespace |
| OLD | NEW |