aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sksl/SkSLParser.cpp
diff options
context:
space:
mode:
authorGravatar Ethan Nicholas <ethannicholas@google.com>2017-06-27 14:36:24 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-06-27 14:36:44 +0000
commited50200682e0de72c3abecaa4d5324ebcd1ed9f9 (patch)
treef991fa9668072f9b87a9929c7834b55cd9175fff /src/sksl/SkSLParser.cpp
parentccf59917d3fe7aaf59de714acfbd0596503f324f (diff)
Revert "sksl fragment processor support"
This reverts commit ccf59917d3fe7aaf59de714acfbd0596503f324f. Reason for revert: breaking iOS bots Original change's description: > sksl fragment processor support > > Bug: skia: > Change-Id: Ia3b0305c2b0c78074303831f628fb01852b90d34 > Reviewed-on: https://skia-review.googlesource.com/17843 > Commit-Queue: Ethan Nicholas <ethannicholas@google.com> > Reviewed-by: Ben Wagner <benjaminwagner@google.com> > Reviewed-by: Mike Klein <mtklein@google.com> TBR=mtklein@google.com,benjaminwagner@google.com,ethannicholas@google.com Change-Id: I0a33060c7c42c7b44c5c13d443ac42958291c2f1 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: skia: Reviewed-on: https://skia-review.googlesource.com/20962 Reviewed-by: Ethan Nicholas <ethannicholas@google.com> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Diffstat (limited to 'src/sksl/SkSLParser.cpp')
-rw-r--r--src/sksl/SkSLParser.cpp158
1 files changed, 23 insertions, 135 deletions
diff --git a/src/sksl/SkSLParser.cpp b/src/sksl/SkSLParser.cpp
index 18ca311ee7..5e8ec6398b 100644
--- a/src/sksl/SkSLParser.cpp
+++ b/src/sksl/SkSLParser.cpp
@@ -52,7 +52,6 @@ static_assert(YY_FLEX_MAJOR_VERSION * 10000 + YY_FLEX_MINOR_VERSION * 100 +
#include "ast/SkSLASTPrecision.h"
#include "ast/SkSLASTPrefixExpression.h"
#include "ast/SkSLASTReturnStatement.h"
-#include "ast/SkSLASTSection.h"
#include "ast/SkSLASTStatement.h"
#include "ast/SkSLASTSuffixExpression.h"
#include "ast/SkSLASTSwitchCase.h"
@@ -114,7 +113,7 @@ Parser::~Parser() {
layoutlex_destroy(fLayoutScanner);
}
-/* (precision | directive | section | declaration)* END_OF_FILE */
+/* (precision | directive | declaration)* END_OF_FILE */
std::vector<std::unique_ptr<ASTDeclaration>> Parser::file() {
std::vector<std::unique_ptr<ASTDeclaration>> result;
for (;;) {
@@ -135,13 +134,6 @@ std::vector<std::unique_ptr<ASTDeclaration>> Parser::file() {
}
break;
}
- case Token::SECTION: {
- std::unique_ptr<ASTDeclaration> section = this->section();
- if (section) {
- result.push_back(std::move(section));
- }
- break;
- }
default: {
std::unique_ptr<ASTDeclaration> decl = this->declaration();
if (!decl) {
@@ -153,7 +145,7 @@ std::vector<std::unique_ptr<ASTDeclaration>> Parser::file() {
}
}
-Token Parser::nextRawToken() {
+Token Parser::nextToken() {
if (fPushback.fKind != Token::INVALID_TOKEN) {
Token result = fPushback;
fPushback.fKind = Token::INVALID_TOKEN;
@@ -161,16 +153,25 @@ Token Parser::nextRawToken() {
return result;
}
int token = sksllex(fScanner);
- return Token(Position(skslget_lineno(fScanner), -1), (Token::Kind) token,
- String(skslget_text(fScanner)));
-}
-
-Token Parser::nextToken() {
- Token token;
- do {
- token = this->nextRawToken();
- } while (token.fKind == Token::WHITESPACE);
- return token;
+ String text;
+ switch ((Token::Kind) token) {
+ case Token::IDENTIFIER: // fall through
+ case Token::INT_LITERAL: // fall through
+ case Token::FLOAT_LITERAL: // fall through
+ case Token::DIRECTIVE:
+ text = String(skslget_text(fScanner));
+ break;
+ default:
+#ifdef SK_DEBUG
+ text = String(skslget_text(fScanner));
+#endif
+ break;
+ }
+ Position p = Position(skslget_lineno(fScanner), -1);
+ if (token == Token::INVALID_TOKEN) {
+ this->error(p, "invalid token: '" + text + "'");
+ }
+ return Token(p, (Token::Kind) token, text);
}
void Parser::pushback(Token t) {
@@ -295,56 +296,6 @@ std::unique_ptr<ASTDeclaration> Parser::directive() {
}
}
-/* SECTION LBRACE (LPAREN IDENTIFIER RPAREN)? <any sequence of tokens with balanced braces>
- RBRACE */
-std::unique_ptr<ASTDeclaration> Parser::section() {
- Token start;
- if (!this->expect(Token::SECTION, "a section token", &start)) {
- return nullptr;
- }
- String argument;
- if (this->peek().fKind == Token::LPAREN) {
- this->nextToken();
- Token argToken;
- if (!this->expect(Token::IDENTIFIER, "an identifier", &argToken)) {
- return nullptr;
- }
- argument = argToken.fText;
- if (!this->expect(Token::RPAREN, "')'")) {
- return nullptr;
- }
- }
- if (!this->expect(Token::LBRACE, "'{'")) {
- return nullptr;
- }
- String text;
- int level = 1;
- for (;;) {
- Token next = this->nextRawToken();
- switch (next.fKind) {
- case Token::LBRACE:
- ++level;
- break;
- case Token::RBRACE:
- --level;
- break;
- case Token::END_OF_FILE:
- this->error(start.fPosition, "reached end of file while parsing section");
- return nullptr;
- default:
- break;
- }
- if (!level) {
- break;
- }
- text += next.fText;
- }
- return std::unique_ptr<ASTDeclaration>(new ASTSection(start.fPosition,
- String(start.fText.c_str() + 1),
- argument,
- text));
-}
-
/* modifiers (structVarDeclaration | type IDENTIFIER ((LPAREN parameter
(COMMA parameter)* RPAREN (block | SEMICOLON)) | SEMICOLON) | interfaceBlock) */
std::unique_ptr<ASTDeclaration> Parser::declaration() {
@@ -593,61 +544,6 @@ int Parser::layoutInt() {
return -1;
}
-/** EQ <any sequence of tokens with balanced parentheses and no top-level comma> */
-String Parser::layoutCode() {
- if (!this->expect(Token::EQ, "'='")) {
- return "";
- }
- Token start = this->peek();
- String code;
- int level = 1;
- bool done = false;
- while (!done) {
- Token next = this->peek();
- switch (next.fKind) {
- case Token::LPAREN:
- ++level;
- break;
- case Token::RPAREN:
- --level;
- break;
- case Token::COMMA:
- if (level == 1) {
- done = true;
- }
- break;
- case Token::END_OF_FILE:
- this->error(start.fPosition, "reached end of file while parsing layout");
- return nullptr;
- default:
- break;
- }
- if (!level) {
- done = true;
- }
- if (!done) {
- code += this->nextRawToken().fText;
- }
- }
- return code;
-}
-
-/** (EQ IDENTIFIER('identity'))? */
-Layout::Key Parser::layoutKey() {
- if (this->peek().fKind == Token::EQ) {
- this->expect(Token::EQ, "'='");
- Token key;
- if (this->expect(Token::IDENTIFIER, "an identifer", &key)) {
- if (key.fText == "identity") {
- return Layout::kIdentity_Key;
- } else {
- this->error(key.fPosition, "unsupported layout key");
- }
- }
- }
- return Layout::kKey_Key;
-}
-
/* LAYOUT LPAREN IDENTIFIER (EQ INT_LITERAL)? (COMMA IDENTIFIER (EQ INT_LITERAL)?)* RPAREN */
Layout Parser::layout() {
int location = -1;
@@ -665,13 +561,11 @@ Layout Parser::layout() {
Layout::Primitive primitive = Layout::kUnspecified_Primitive;
int maxVertices = -1;
int invocations = -1;
- String when;
- Layout::Key key = Layout::kNo_Key;
if (this->checkNext(Token::LAYOUT)) {
if (!this->expect(Token::LPAREN, "'('")) {
return Layout(location, offset, binding, index, set, builtin, inputAttachmentIndex,
originUpperLeft, overrideCoverage, blendSupportAllEquations, format,
- pushConstant, primitive, maxVertices, invocations, when, key);
+ pushConstant, primitive, maxVertices, invocations);
}
for (;;) {
Token t = this->nextToken();
@@ -741,12 +635,6 @@ Layout Parser::layout() {
case Token::INVOCATIONS:
invocations = this->layoutInt();
break;
- case Token::WHEN:
- when = this->layoutCode();
- break;
- case Token::KEY:
- key = this->layoutKey();
- break;
}
} else if (Layout::ReadFormat(t.fText, &format)) {
// AST::ReadFormat stored the result in 'format'.
@@ -764,7 +652,7 @@ Layout Parser::layout() {
}
return Layout(location, offset, binding, index, set, builtin, inputAttachmentIndex,
originUpperLeft, overrideCoverage, blendSupportAllEquations, format,
- pushConstant, primitive, maxVertices, invocations, when, key);
+ pushConstant, primitive, maxVertices, invocations);
}
/* layout? (UNIFORM | CONST | IN | OUT | INOUT | LOWP | MEDIUMP | HIGHP | FLAT | NOPERSPECTIVE |