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 790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 } | 801 } |
802 if (!this->expect(Token::LPAREN, "'('")) { | 802 if (!this->expect(Token::LPAREN, "'('")) { |
803 return nullptr; | 803 return nullptr; |
804 } | 804 } |
805 std::unique_ptr<ASTStatement> initializer; | 805 std::unique_ptr<ASTStatement> initializer; |
806 Token nextToken = this->peek(); | 806 Token nextToken = this->peek(); |
807 switch (nextToken.fKind) { | 807 switch (nextToken.fKind) { |
808 case Token::SEMICOLON: | 808 case Token::SEMICOLON: |
809 this->nextToken(); | 809 this->nextToken(); |
810 break; | 810 break; |
811 case Token::CONST: | 811 case Token::CONST: { |
| 812 std::unique_ptr<ASTVarDeclarations> vd = this->varDeclarations(); |
| 813 if (!vd) { |
| 814 return nullptr; |
| 815 } |
812 initializer = std::unique_ptr<ASTStatement>(new ASTVarDeclarationSta
tement( | 816 initializer = std::unique_ptr<ASTStatement>(new ASTVarDeclarationSta
tement( |
813 this->
varDeclarations())); | 817
std::move(vd))); |
814 break; | 818 break; |
815 case Token::IDENTIFIER: | 819 } |
| 820 case Token::IDENTIFIER: { |
816 if (this->isType(nextToken.fText)) { | 821 if (this->isType(nextToken.fText)) { |
| 822 std::unique_ptr<ASTVarDeclarations> vd = this->varDeclarations()
; |
| 823 if (!vd) { |
| 824 return nullptr; |
| 825 } |
817 initializer = std::unique_ptr<ASTStatement>(new ASTVarDeclaratio
nStatement( | 826 initializer = std::unique_ptr<ASTStatement>(new ASTVarDeclaratio
nStatement( |
818 this->
varDeclarations())); | 827
std::move(vd))); |
819 break; | 828 break; |
820 } | 829 } |
821 // fall through | 830 } // fall through |
822 default: | 831 default: |
823 initializer = this->expressionStatement(); | 832 initializer = this->expressionStatement(); |
824 } | 833 } |
825 std::unique_ptr<ASTExpression> test; | 834 std::unique_ptr<ASTExpression> test; |
826 if (this->peek().fKind != Token::SEMICOLON) { | 835 if (this->peek().fKind != Token::SEMICOLON) { |
827 test = this->expression(); | 836 test = this->expression(); |
828 if (!test) { | 837 if (!test) { |
829 return nullptr; | 838 return nullptr; |
830 } | 839 } |
831 } | 840 } |
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1435 bool Parser::identifier(std::string* dest) { | 1444 bool Parser::identifier(std::string* dest) { |
1436 Token t; | 1445 Token t; |
1437 if (this->expect(Token::IDENTIFIER, "identifier", &t)) { | 1446 if (this->expect(Token::IDENTIFIER, "identifier", &t)) { |
1438 *dest = t.fText; | 1447 *dest = t.fText; |
1439 return true; | 1448 return true; |
1440 } | 1449 } |
1441 return false; | 1450 return false; |
1442 } | 1451 } |
1443 | 1452 |
1444 } // namespace | 1453 } // namespace |
OLD | NEW |