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 | DIRECTIVE(#extension) IDENTIFIER COLON IDEN
TIFIER */ | 188 /* DIRECTIVE(#version) INT_LITERAL ("es" | "compatibility")? | |
| 189 DIRECTIVE(#extension) IDENTIFIER COLON IDENTIFIER */ |
189 std::unique_ptr<ASTDeclaration> Parser::directive() { | 190 std::unique_ptr<ASTDeclaration> Parser::directive() { |
190 Token start; | 191 Token start; |
191 if (!this->expect(Token::DIRECTIVE, "a directive", &start)) { | 192 if (!this->expect(Token::DIRECTIVE, "a directive", &start)) { |
192 return nullptr; | 193 return nullptr; |
193 } | 194 } |
194 if (start.fText == "#version") { | 195 if (start.fText == "#version") { |
195 this->expect(Token::INT_LITERAL, "a version number"); | 196 this->expect(Token::INT_LITERAL, "a version number"); |
196 // ignored for now | 197 Token next = this->peek(); |
| 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 |
197 return nullptr; | 203 return nullptr; |
198 } else if (start.fText == "#extension") { | 204 } else if (start.fText == "#extension") { |
199 Token name; | 205 Token name; |
200 if (!this->expect(Token::IDENTIFIER, "an identifier", &name)) { | 206 if (!this->expect(Token::IDENTIFIER, "an identifier", &name)) { |
201 return nullptr; | 207 return nullptr; |
202 } | 208 } |
203 if (!this->expect(Token::COLON, "':'")) { | 209 if (!this->expect(Token::COLON, "':'")) { |
204 return nullptr; | 210 return nullptr; |
205 } | 211 } |
206 // FIXME: need to start paying attention to this token | 212 // FIXME: need to start paying attention to this token |
(...skipping 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1398 bool Parser::identifier(std::string* dest) { | 1404 bool Parser::identifier(std::string* dest) { |
1399 Token t; | 1405 Token t; |
1400 if (this->expect(Token::IDENTIFIER, "identifier", &t)) { | 1406 if (this->expect(Token::IDENTIFIER, "identifier", &t)) { |
1401 *dest = t.fText; | 1407 *dest = t.fText; |
1402 return true; | 1408 return true; |
1403 } | 1409 } |
1404 return false; | 1410 return false; |
1405 } | 1411 } |
1406 | 1412 |
1407 } // namespace | 1413 } // namespace |
OLD | NEW |