fixed an SkSL parse issue

Change-Id: Icc44b10184c7be564fe7d759075a9c87c53af712
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/242141
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
This commit is contained in:
Ethan Nicholas 2019-09-17 16:18:22 -04:00 committed by Skia Commit-Bot
parent 0033008d95
commit 5a9a0b388e
2 changed files with 13 additions and 2 deletions

View File

@ -1927,14 +1927,19 @@ ASTNode::ID Parser::postfixExpression() {
return ASTNode::ID::Invalid();
}
for (;;) {
switch (this->peek().fKind) {
Token t = this->peek();
switch (t.fKind) {
case Token::FLOAT_LITERAL:
if (this->text(t)[0] != '.') {
return result;
}
// fall through
case Token::LBRACKET:
case Token::DOT:
case Token::LPAREN:
case Token::PLUSPLUS:
case Token::MINUSMINUS:
case Token::COLONCOLON:
case Token::FLOAT_LITERAL:
if (!depth.increase()) {
return ASTNode::ID::Invalid();
}

View File

@ -522,3 +522,9 @@ DEF_TEST(SkSLDuplicateOutput, r) {
"layout (location=0, index=0) out half4 duplicateOutput;",
"error: 1: out location=0, index=0 is reserved for sk_FragColor\n1 error\n");
}
DEF_TEST(SkSLSpuriousFloat, r) {
test_failure(r,
"void main() { float x; x = 1.5 2.5; }",
"error: 1: expected ';', but found '2.5'\n1 error\n");
}