Mark GLSL reserved names as reserved in SkSL grammar.

We now reject every reserved name in the ES2 docs as an unexpected
token, except for the rule that all names beginning with `gl_` are
reserved. (Unfortunately, sksl_frag bends the rules by directly
declaring a builtin variable named `gl_SecondaryFragColorEXT`.)

Change-Id: I5dcb40b754720ca97fe3d80e2f9072beaa39fcdb
Bug: skia:11115
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/454737
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
This commit is contained in:
John Stiles 2021-09-30 12:48:40 -04:00 committed by SkCQ
parent 4aef06d231
commit 57f3fc4cde
83 changed files with 1448 additions and 700 deletions

View File

@ -123,6 +123,44 @@ sksl_error_tests = [
"/sksl/errors/RedeclareStructTypeWithName.sksl",
"/sksl/errors/RedeclareUserType.sksl",
"/sksl/errors/RedeclareVariable.sksl",
"/sksl/errors/ReservedNameAsm.sksl",
"/sksl/errors/ReservedNameCast.sksl",
"/sksl/errors/ReservedNameDouble.sksl",
"/sksl/errors/ReservedNameDvec2.sksl",
"/sksl/errors/ReservedNameDvec3.sksl",
"/sksl/errors/ReservedNameDvec4.sksl",
"/sksl/errors/ReservedNameEnum.sksl",
"/sksl/errors/ReservedNameExtern.sksl",
"/sksl/errors/ReservedNameExternal.sksl",
"/sksl/errors/ReservedNameFixed.sksl",
"/sksl/errors/ReservedNameFvec2.sksl",
"/sksl/errors/ReservedNameFvec3.sksl",
"/sksl/errors/ReservedNameFvec4.sksl",
"/sksl/errors/ReservedNameGoto.sksl",
"/sksl/errors/ReservedNameHvec2.sksl",
"/sksl/errors/ReservedNameHvec3.sksl",
"/sksl/errors/ReservedNameHvec4.sksl",
"/sksl/errors/ReservedNameInput.sksl",
"/sksl/errors/ReservedNameInterface.sksl",
"/sksl/errors/ReservedNameLong.sksl",
"/sksl/errors/ReservedNameNamespace.sksl",
"/sksl/errors/ReservedNameOutput.sksl",
"/sksl/errors/ReservedNamePacked.sksl",
"/sksl/errors/ReservedNamePublic.sksl",
"/sksl/errors/ReservedNameSampler1DShadow.sksl",
"/sksl/errors/ReservedNameSampler2DRectShadow.sksl",
"/sksl/errors/ReservedNameSampler2DShadow.sksl",
"/sksl/errors/ReservedNameSampler3DRect.sksl",
"/sksl/errors/ReservedNameSizeof.sksl",
"/sksl/errors/ReservedNameStatic.sksl",
"/sksl/errors/ReservedNameSuperp.sksl",
"/sksl/errors/ReservedNameTemplate.sksl",
"/sksl/errors/ReservedNameThis.sksl",
"/sksl/errors/ReservedNameTypedef.sksl",
"/sksl/errors/ReservedNameUnion.sksl",
"/sksl/errors/ReservedNameUnsigned.sksl",
"/sksl/errors/ReservedNameUsing.sksl",
"/sksl/errors/ReservedNameVolatile.sksl",
"/sksl/errors/ReturnDifferentType.sksl",
"/sksl/errors/ReturnFromVoid.sksl",
"/sksl/errors/ReturnMissingValue.sksl",

View File

@ -0,0 +1 @@
int asm;

View File

@ -0,0 +1 @@
int cast;

View File

@ -0,0 +1 @@
int double;

View File

@ -0,0 +1 @@
int dvec2;

View File

@ -0,0 +1 @@
int dvec3;

View File

@ -0,0 +1 @@
int dvec4;

View File

@ -0,0 +1 @@
int enum;

View File

@ -0,0 +1 @@
int extern;

View File

@ -0,0 +1 @@
int external;

View File

@ -0,0 +1 @@
int fixed;

View File

@ -0,0 +1 @@
int fvec2;

View File

@ -0,0 +1 @@
int fvec3;

View File

@ -0,0 +1 @@
int fvec4;

View File

@ -0,0 +1 @@
int goto;

View File

@ -0,0 +1 @@
int hvec2;

View File

@ -0,0 +1 @@
int hvec3;

View File

@ -0,0 +1 @@
int hvec4;

View File

@ -0,0 +1 @@
int input;

View File

@ -0,0 +1 @@
int interface;

View File

@ -0,0 +1 @@
int long;

View File

@ -0,0 +1 @@
int namespace;

View File

@ -0,0 +1 @@
int output;

View File

@ -0,0 +1 @@
int packed;

View File

@ -0,0 +1 @@
int public;

View File

@ -0,0 +1 @@
int sampler1DShadow;

View File

@ -0,0 +1 @@
int sampler2DRectShadow;

View File

@ -0,0 +1 @@
int sampler2DShadow;

View File

@ -0,0 +1 @@
int sampler3DRect;

View File

@ -0,0 +1 @@
int sizeof;

View File

@ -0,0 +1 @@
int static;

View File

@ -0,0 +1 @@
int superp;

View File

@ -0,0 +1 @@
int template;

View File

@ -0,0 +1 @@
int this;

View File

@ -0,0 +1 @@
int typedef;

View File

@ -0,0 +1 @@
int union;

View File

@ -0,0 +1 @@
int unsigned;

View File

@ -0,0 +1 @@
int using;

View File

@ -0,0 +1 @@
int volatile;

File diff suppressed because it is too large Load Diff

View File

@ -51,6 +51,7 @@ struct Token {
TK_MEDIUMP,
TK_LOWP,
TK_ES3,
TK_RESERVED,
TK_IDENTIFIER,
TK_DIRECTIVE,
TK_LPAREN,

File diff suppressed because it is too large Load Diff

View File

@ -2417,7 +2417,7 @@ static uint8_t SKSL_INCLUDE_sksl_public[] = {199,3,
46,13,2,2,
1,
45,
55,139,2,0,3,0,1,2,50,
55,139,2,0,3,0,1,2,51,
27,
46,153,0,185,0,2,
45,
@ -2434,7 +2434,7 @@ static uint8_t SKSL_INCLUDE_sksl_public[] = {199,3,
46,8,2,2,
1,
45,
55,141,2,0,3,0,1,2,50,
55,141,2,0,3,0,1,2,51,
27,
46,145,0,177,0,2,
45,

View File

@ -43,8 +43,9 @@ HIGHP = "highp"
MEDIUMP = "mediump"
LOWP = "lowp"
ES3 = "$es3"
IDENTIFIER = [a-zA-Z_$]([0-9]|[a-zA-Z_$])*
DIRECTIVE = #[a-zA-Z_$]([0-9]|[a-zA-Z_$])*
RESERVED = asm|class|union|enum|typedef|template|this|packed|goto|volatile|public|static|extern|external|interface|long|double|fixed|unsigned|superp|input|output|hvec[234]|dvec[234]|fvec[234]|sampler[12]DShadow|sampler3DRect|sampler2DRectShadow|sizeof|cast|namespace|using
IDENTIFIER = [a-zA-Z_$][0-9a-zA-Z_$]*
DIRECTIVE = #[a-zA-Z_$][0-9a-zA-Z_$]*
LPAREN = "("
RPAREN = ")"
LBRACE = "{"

View File

@ -0,0 +1,4 @@
### Compilation failed:
error: 1: expected an identifier, but found 'asm'
1 error

View File

@ -0,0 +1,4 @@
### Compilation failed:
error: 1: expected an identifier, but found 'cast'
1 error

View File

@ -0,0 +1,4 @@
### Compilation failed:
error: 1: expected an identifier, but found 'double'
1 error

View File

@ -0,0 +1,4 @@
### Compilation failed:
error: 1: expected an identifier, but found 'dvec2'
1 error

View File

@ -0,0 +1,4 @@
### Compilation failed:
error: 1: expected an identifier, but found 'dvec3'
1 error

View File

@ -0,0 +1,4 @@
### Compilation failed:
error: 1: expected an identifier, but found 'dvec4'
1 error

View File

@ -0,0 +1,4 @@
### Compilation failed:
error: 1: expected an identifier, but found 'enum'
1 error

View File

@ -0,0 +1,4 @@
### Compilation failed:
error: 1: expected an identifier, but found 'extern'
1 error

View File

@ -0,0 +1,4 @@
### Compilation failed:
error: 1: expected an identifier, but found 'external'
1 error

View File

@ -0,0 +1,4 @@
### Compilation failed:
error: 1: expected an identifier, but found 'fixed'
1 error

View File

@ -0,0 +1,4 @@
### Compilation failed:
error: 1: expected an identifier, but found 'fvec2'
1 error

View File

@ -0,0 +1,4 @@
### Compilation failed:
error: 1: expected an identifier, but found 'fvec3'
1 error

View File

@ -0,0 +1,4 @@
### Compilation failed:
error: 1: expected an identifier, but found 'fvec4'
1 error

View File

@ -0,0 +1,4 @@
### Compilation failed:
error: 1: expected an identifier, but found 'goto'
1 error

View File

@ -0,0 +1,4 @@
### Compilation failed:
error: 1: expected an identifier, but found 'hvec2'
1 error

View File

@ -0,0 +1,4 @@
### Compilation failed:
error: 1: expected an identifier, but found 'hvec3'
1 error

View File

@ -0,0 +1,4 @@
### Compilation failed:
error: 1: expected an identifier, but found 'hvec4'
1 error

View File

@ -0,0 +1,4 @@
### Compilation failed:
error: 1: expected an identifier, but found 'input'
1 error

View File

@ -0,0 +1,4 @@
### Compilation failed:
error: 1: expected an identifier, but found 'interface'
1 error

View File

@ -0,0 +1,4 @@
### Compilation failed:
error: 1: expected an identifier, but found 'long'
1 error

View File

@ -0,0 +1,4 @@
### Compilation failed:
error: 1: expected an identifier, but found 'namespace'
1 error

View File

@ -0,0 +1,4 @@
### Compilation failed:
error: 1: expected an identifier, but found 'output'
1 error

View File

@ -0,0 +1,4 @@
### Compilation failed:
error: 1: expected an identifier, but found 'packed'
1 error

View File

@ -0,0 +1,4 @@
### Compilation failed:
error: 1: expected an identifier, but found 'public'
1 error

View File

@ -0,0 +1,4 @@
### Compilation failed:
error: 1: expected an identifier, but found 'sampler1DShadow'
1 error

View File

@ -0,0 +1,4 @@
### Compilation failed:
error: 1: expected an identifier, but found 'sampler2DRectShadow'
1 error

View File

@ -0,0 +1,4 @@
### Compilation failed:
error: 1: expected an identifier, but found 'sampler2DShadow'
1 error

View File

@ -0,0 +1,4 @@
### Compilation failed:
error: 1: expected an identifier, but found 'sampler3DRect'
1 error

View File

@ -0,0 +1,4 @@
### Compilation failed:
error: 1: expected an identifier, but found 'sizeof'
1 error

View File

@ -0,0 +1,4 @@
### Compilation failed:
error: 1: expected an identifier, but found 'static'
1 error

View File

@ -0,0 +1,4 @@
### Compilation failed:
error: 1: expected an identifier, but found 'superp'
1 error

View File

@ -0,0 +1,4 @@
### Compilation failed:
error: 1: expected an identifier, but found 'template'
1 error

View File

@ -0,0 +1,4 @@
### Compilation failed:
error: 1: expected an identifier, but found 'this'
1 error

View File

@ -0,0 +1,4 @@
### Compilation failed:
error: 1: expected an identifier, but found 'typedef'
1 error

View File

@ -0,0 +1,4 @@
### Compilation failed:
error: 1: expected an identifier, but found 'union'
1 error

View File

@ -0,0 +1,4 @@
### Compilation failed:
error: 1: expected an identifier, but found 'unsigned'
1 error

View File

@ -0,0 +1,4 @@
### Compilation failed:
error: 1: expected an identifier, but found 'using'
1 error

View File

@ -0,0 +1,4 @@
### Compilation failed:
error: 1: expected an identifier, but found 'volatile'
1 error

View File

@ -0,0 +1,4 @@
### Compilation failed:
error: 1: expected an identifier, but found 'asm'
1 error