| 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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 this->error(p.fPosition, "expected 'lowp', 'mediump', or 'highp', bu
t found '" + | 178 this->error(p.fPosition, "expected 'lowp', 'mediump', or 'highp', bu
t found '" + |
| 179 p.fText + "'"); | 179 p.fText + "'"); |
| 180 return; | 180 return; |
| 181 } | 181 } |
| 182 if (!this->type()) { | 182 if (!this->type()) { |
| 183 return; | 183 return; |
| 184 } | 184 } |
| 185 this->expect(Token::SEMICOLON, "';'"); | 185 this->expect(Token::SEMICOLON, "';'"); |
| 186 } | 186 } |
| 187 | 187 |
| 188 /* DIRECTIVE(#version) INT_LITERAL ("es" | "compatibility")? | | 188 /* DIRECTIVE(#version) INT_LITERAL | DIRECTIVE(#extension) IDENTIFIER COLON IDEN
TIFIER */ |
| 189 DIRECTIVE(#extension) IDENTIFIER COLON IDENTIFIER */ | |
| 190 std::unique_ptr<ASTDeclaration> Parser::directive() { | 189 std::unique_ptr<ASTDeclaration> Parser::directive() { |
| 191 Token start; | 190 Token start; |
| 192 if (!this->expect(Token::DIRECTIVE, "a directive", &start)) { | 191 if (!this->expect(Token::DIRECTIVE, "a directive", &start)) { |
| 193 return nullptr; | 192 return nullptr; |
| 194 } | 193 } |
| 195 if (start.fText == "#version") { | 194 if (start.fText == "#version") { |
| 196 this->expect(Token::INT_LITERAL, "a version number"); | 195 this->expect(Token::INT_LITERAL, "a version number"); |
| 197 Token next = this->peek(); | 196 // ignored for now |
| 198 if (next.fText == "es" || next.fText == "compatibility") { | |
| 199 this->nextToken(); | |
| 200 } | |
| 201 // version is ignored for now; it will eventually become an error when w
e stop pretending | |
| 202 // to be GLSL | |
| 203 return nullptr; | 197 return nullptr; |
| 204 } else if (start.fText == "#extension") { | 198 } else if (start.fText == "#extension") { |
| 205 Token name; | 199 Token name; |
| 206 if (!this->expect(Token::IDENTIFIER, "an identifier", &name)) { | 200 if (!this->expect(Token::IDENTIFIER, "an identifier", &name)) { |
| 207 return nullptr; | 201 return nullptr; |
| 208 } | 202 } |
| 209 if (!this->expect(Token::COLON, "':'")) { | 203 if (!this->expect(Token::COLON, "':'")) { |
| 210 return nullptr; | 204 return nullptr; |
| 211 } | 205 } |
| 212 // FIXME: need to start paying attention to this token | 206 // FIXME: need to start paying attention to this token |
| (...skipping 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1404 bool Parser::identifier(std::string* dest) { | 1398 bool Parser::identifier(std::string* dest) { |
| 1405 Token t; | 1399 Token t; |
| 1406 if (this->expect(Token::IDENTIFIER, "identifier", &t)) { | 1400 if (this->expect(Token::IDENTIFIER, "identifier", &t)) { |
| 1407 *dest = t.fText; | 1401 *dest = t.fText; |
| 1408 return true; | 1402 return true; |
| 1409 } | 1403 } |
| 1410 return false; | 1404 return false; |
| 1411 } | 1405 } |
| 1412 | 1406 |
| 1413 } // namespace | 1407 } // namespace |
| OLD | NEW |