mirror of
https://github.com/alecthomas/chroma.git
synced 2025-03-17 20:58:08 +02:00
Add WebGPU Shading Language lexer (#776)
https://w3.org/TR/WGSL Generated from the Pygments lexer I wrote, in https://github.com/pygments/pygments/pull/2386
This commit is contained in:
parent
4f02bc5f68
commit
0eecb2ae57
61
lexers/embedded/wgsl.xml
Normal file
61
lexers/embedded/wgsl.xml
Normal file
File diff suppressed because one or more lines are too long
5
lexers/testdata/wgsl.attribute.actual
vendored
Normal file
5
lexers/testdata/wgsl.attribute.actual
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
@id(0) override x:i32 = 1;
|
||||
@ id(1) override y:i32 = 2;
|
||||
@//comment
|
||||
id(1) override z:i32 = 3;
|
||||
@must_use fn foo() -> i32 { return 32; }
|
74
lexers/testdata/wgsl.attribute.expected
vendored
Normal file
74
lexers/testdata/wgsl.attribute.expected
vendored
Normal file
@ -0,0 +1,74 @@
|
||||
[
|
||||
{"type":"NameDecorator","value":"@id"},
|
||||
{"type":"Punctuation","value":"("},
|
||||
{"type":"LiteralNumberInteger","value":"0"},
|
||||
{"type":"Punctuation","value":")"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"KeywordDeclaration","value":"override"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"x"},
|
||||
{"type":"Punctuation","value":":"},
|
||||
{"type":"NameBuiltin","value":"i32"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralNumberInteger","value":"1"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"NameDecorator","value":"@"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"NameDecorator","value":"id"},
|
||||
{"type":"Punctuation","value":"("},
|
||||
{"type":"LiteralNumberInteger","value":"1"},
|
||||
{"type":"Punctuation","value":")"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"KeywordDeclaration","value":"override"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"y"},
|
||||
{"type":"Punctuation","value":":"},
|
||||
{"type":"NameBuiltin","value":"i32"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralNumberInteger","value":"2"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"NameDecorator","value":"@"},
|
||||
{"type":"CommentSingle","value":"//comment\n"},
|
||||
{"type":"NameDecorator","value":"id"},
|
||||
{"type":"Punctuation","value":"("},
|
||||
{"type":"LiteralNumberInteger","value":"1"},
|
||||
{"type":"Punctuation","value":")"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"KeywordDeclaration","value":"override"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"z"},
|
||||
{"type":"Punctuation","value":":"},
|
||||
{"type":"NameBuiltin","value":"i32"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralNumberInteger","value":"3"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"NameDecorator","value":"@must_use"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Keyword","value":"fn"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"foo"},
|
||||
{"type":"Punctuation","value":"()"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Punctuation","value":"-\u003e"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"NameBuiltin","value":"i32"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Punctuation","value":"{"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Keyword","value":"return"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralNumberInteger","value":"32"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Punctuation","value":"}"},
|
||||
{"type":"TextWhitespace","value":"\n"}
|
||||
]
|
8
lexers/testdata/wgsl.block.comment.actual
vendored
Normal file
8
lexers/testdata/wgsl.block.comment.actual
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
/**/
|
||||
/*block with newline
|
||||
*/
|
||||
/*block with line
|
||||
ending comment// */
|
||||
/* nested /*
|
||||
*/
|
||||
*/
|
11
lexers/testdata/wgsl.block.comment.expected
vendored
Normal file
11
lexers/testdata/wgsl.block.comment.expected
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
[
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"CommentMultiline","value":"/**/"},
|
||||
{"type":"TextWhitespace","value":"\n "},
|
||||
{"type":"CommentMultiline","value":"/*block with newline\n */"},
|
||||
{"type":"TextWhitespace","value":"\n "},
|
||||
{"type":"CommentMultiline","value":"/*block with line\n ending comment// */"},
|
||||
{"type":"TextWhitespace","value":"\n "},
|
||||
{"type":"CommentMultiline","value":"/* nested /*\n */\n */"},
|
||||
{"type":"TextWhitespace","value":"\n"}
|
||||
]
|
50
lexers/testdata/wgsl.const.numbers.actual
vendored
Normal file
50
lexers/testdata/wgsl.const.numbers.actual
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
const a = 0;
|
||||
const au = 0u;
|
||||
const ai = 0i;
|
||||
const b = 12345;
|
||||
const bu = 12345u;
|
||||
const bi= 12345i;
|
||||
const c = 0x0;
|
||||
const cu = 0x0u;
|
||||
const ci = 0x0i;
|
||||
const d = 0x12345;
|
||||
const di = 0x12345i;
|
||||
const du = 0x12345u;
|
||||
const eh = 0h;
|
||||
const ef = 0f;
|
||||
const f = 1.;
|
||||
const fh = 1.h;
|
||||
const ff = 1.f;
|
||||
const g = .1;
|
||||
const gh = .1h;
|
||||
const gf = .1f;
|
||||
const g = 1e1;
|
||||
const gh = 1e1h;
|
||||
const gf = 1e1f;
|
||||
const h = 1e+1;
|
||||
const hh = 1e+1h;
|
||||
const hf = 1e+1f;
|
||||
const i = 1e-1;
|
||||
const ih = 1e-1h;
|
||||
const if = 1e-1f;
|
||||
const j = 1.0e+1;
|
||||
const jh = 1.0e+1h;
|
||||
const jf= 1.0e+1f;
|
||||
const k = 1.0e-1;
|
||||
const kh = 1.0e-1h;
|
||||
const kf= 1.0e-1f;
|
||||
const l = 0x1p1;
|
||||
const lh = 0x1p1h;
|
||||
const lf = 0x1p1f;
|
||||
const m = 0x1p+1;
|
||||
const mh = 0x1p+1h;
|
||||
const mf = 0x1p+1f;
|
||||
const n = 0x1p-1;
|
||||
const nh = 0x1p-1h;
|
||||
const nf = 0x1p-1f;
|
||||
const o = 0x1.p1;
|
||||
const oh = 0x1.p1h;
|
||||
const of = 0x1.p1f;
|
||||
const p = 0x.1p1;
|
||||
const ph = 0x.1p1h;
|
||||
const pf = 0x.1p1f;
|
449
lexers/testdata/wgsl.const.numbers.expected
vendored
Normal file
449
lexers/testdata/wgsl.const.numbers.expected
vendored
Normal file
@ -0,0 +1,449 @@
|
||||
[
|
||||
{"type":"KeywordDeclaration","value":"const"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"a"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralNumberInteger","value":"0"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"KeywordDeclaration","value":"const"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"au"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralNumberInteger","value":"0u"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"KeywordDeclaration","value":"const"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"ai"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralNumberInteger","value":"0i"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"KeywordDeclaration","value":"const"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"b"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralNumberInteger","value":"12345"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"KeywordDeclaration","value":"const"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"bu"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralNumberInteger","value":"12345u"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"KeywordDeclaration","value":"const"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"bi"},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralNumberInteger","value":"12345i"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"KeywordDeclaration","value":"const"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"c"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralNumberHex","value":"0x0"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"KeywordDeclaration","value":"const"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"cu"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralNumberHex","value":"0x0u"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"KeywordDeclaration","value":"const"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"ci"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralNumberHex","value":"0x0i"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"KeywordDeclaration","value":"const"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"d"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralNumberHex","value":"0x12345"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"KeywordDeclaration","value":"const"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"di"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralNumberHex","value":"0x12345i"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"KeywordDeclaration","value":"const"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"du"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralNumberHex","value":"0x12345u"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"KeywordDeclaration","value":"const"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"eh"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralNumberFloat","value":"0h"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"KeywordDeclaration","value":"const"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"ef"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralNumberFloat","value":"0f"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"KeywordDeclaration","value":"const"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"f"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralNumberFloat","value":"1."},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"KeywordDeclaration","value":"const"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"fh"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralNumberFloat","value":"1.h"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"KeywordDeclaration","value":"const"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"ff"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralNumberFloat","value":"1.f"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"KeywordDeclaration","value":"const"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"g"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralNumberFloat","value":".1"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"KeywordDeclaration","value":"const"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"gh"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralNumberFloat","value":".1h"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"KeywordDeclaration","value":"const"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"gf"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralNumberFloat","value":".1f"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"KeywordDeclaration","value":"const"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"g"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralNumberFloat","value":"1e1"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"KeywordDeclaration","value":"const"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"gh"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralNumberFloat","value":"1e1h"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"KeywordDeclaration","value":"const"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"gf"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralNumberFloat","value":"1e1f"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"KeywordDeclaration","value":"const"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"h"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralNumberFloat","value":"1e+1"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"KeywordDeclaration","value":"const"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"hh"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralNumberFloat","value":"1e+1h"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"KeywordDeclaration","value":"const"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"hf"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralNumberFloat","value":"1e+1f"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"KeywordDeclaration","value":"const"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"i"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralNumberFloat","value":"1e-1"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"KeywordDeclaration","value":"const"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"ih"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralNumberFloat","value":"1e-1h"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"KeywordDeclaration","value":"const"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Keyword","value":"if"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralNumberFloat","value":"1e-1f"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"KeywordDeclaration","value":"const"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"j"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralNumberFloat","value":"1.0e+1"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"KeywordDeclaration","value":"const"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"jh"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralNumberFloat","value":"1.0e+1h"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"KeywordDeclaration","value":"const"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"jf"},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralNumberFloat","value":"1.0e+1f"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"KeywordDeclaration","value":"const"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"k"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralNumberFloat","value":"1.0e-1"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"KeywordDeclaration","value":"const"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"kh"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralNumberFloat","value":"1.0e-1h"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"KeywordDeclaration","value":"const"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"kf"},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralNumberFloat","value":"1.0e-1f"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"KeywordDeclaration","value":"const"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"l"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralNumberFloat","value":"0x1p1"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"KeywordDeclaration","value":"const"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"lh"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralNumberFloat","value":"0x1p1h"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"KeywordDeclaration","value":"const"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"lf"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralNumberFloat","value":"0x1p1f"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"KeywordDeclaration","value":"const"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"m"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralNumberFloat","value":"0x1p+1"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"KeywordDeclaration","value":"const"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"mh"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralNumberFloat","value":"0x1p+1h"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"KeywordDeclaration","value":"const"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"mf"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralNumberFloat","value":"0x1p+1f"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"KeywordDeclaration","value":"const"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"n"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralNumberFloat","value":"0x1p-1"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"KeywordDeclaration","value":"const"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"nh"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralNumberFloat","value":"0x1p-1h"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"KeywordDeclaration","value":"const"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"nf"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralNumberFloat","value":"0x1p-1f"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"KeywordDeclaration","value":"const"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"o"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralNumberFloat","value":"0x1.p1"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"KeywordDeclaration","value":"const"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"oh"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralNumberFloat","value":"0x1.p1h"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"KeywordDeclaration","value":"const"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"KeywordReserved","value":"of"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralNumberFloat","value":"0x1.p1f"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"KeywordDeclaration","value":"const"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"p"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralNumberFloat","value":"0x.1p1"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"KeywordDeclaration","value":"const"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"ph"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralNumberFloat","value":"0x.1p1h"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"KeywordDeclaration","value":"const"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"pf"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralNumberFloat","value":"0x.1p1f"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n"}
|
||||
]
|
3
lexers/testdata/wgsl.line.comment.actual
vendored
Normal file
3
lexers/testdata/wgsl.line.comment.actual
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
// this is a line-ending comment
|
||||
//* embed a bock comment start, after gap of space
|
||||
// /* embed a bock comment start, v2
|
6
lexers/testdata/wgsl.line.comment.expected
vendored
Normal file
6
lexers/testdata/wgsl.line.comment.expected
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
[
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"CommentSingle","value":"// this is a line-ending comment\n"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"CommentSingle","value":"//* embed a bock comment start, after gap of space\n// /* embed a bock comment start, v2\n"}
|
||||
]
|
9
lexers/testdata/wgsl.tiny.render.actual
vendored
Normal file
9
lexers/testdata/wgsl.tiny.render.actual
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
@vertex
|
||||
fn vmain(@location(0) v: vec4<f32>) -> @builtin(position) vec4f {
|
||||
return v;
|
||||
}
|
||||
|
||||
@fragment
|
||||
fn fmain(@builtin(position) pos: vec4f) -> @location(0) vec4f {
|
||||
return vec4f(0.25,0.25,1.0,1.0);
|
||||
}
|
83
lexers/testdata/wgsl.tiny.render.expected
vendored
Normal file
83
lexers/testdata/wgsl.tiny.render.expected
vendored
Normal file
@ -0,0 +1,83 @@
|
||||
[
|
||||
{"type":"NameDecorator","value":"@vertex"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"Keyword","value":"fn"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"vmain"},
|
||||
{"type":"Punctuation","value":"("},
|
||||
{"type":"NameDecorator","value":"@location"},
|
||||
{"type":"Punctuation","value":"("},
|
||||
{"type":"LiteralNumberInteger","value":"0"},
|
||||
{"type":"Punctuation","value":")"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"v"},
|
||||
{"type":"Punctuation","value":":"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"NameBuiltin","value":"vec4"},
|
||||
{"type":"Operator","value":"\u003c"},
|
||||
{"type":"NameBuiltin","value":"f32"},
|
||||
{"type":"Operator","value":"\u003e"},
|
||||
{"type":"Punctuation","value":")"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Punctuation","value":"-\u003e"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"NameDecorator","value":"@builtin"},
|
||||
{"type":"Punctuation","value":"("},
|
||||
{"type":"NameBuiltin","value":"position"},
|
||||
{"type":"Punctuation","value":")"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"NameBuiltin","value":"vec4f"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Punctuation","value":"{"},
|
||||
{"type":"TextWhitespace","value":"\n "},
|
||||
{"type":"Keyword","value":"return"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"v"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"Punctuation","value":"}"},
|
||||
{"type":"TextWhitespace","value":"\n\n"},
|
||||
{"type":"NameDecorator","value":"@fragment"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"Keyword","value":"fn"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"fmain"},
|
||||
{"type":"Punctuation","value":"("},
|
||||
{"type":"NameDecorator","value":"@builtin"},
|
||||
{"type":"Punctuation","value":"("},
|
||||
{"type":"NameBuiltin","value":"position"},
|
||||
{"type":"Punctuation","value":")"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"pos"},
|
||||
{"type":"Punctuation","value":":"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"NameBuiltin","value":"vec4f"},
|
||||
{"type":"Punctuation","value":")"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Punctuation","value":"-\u003e"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"NameDecorator","value":"@location"},
|
||||
{"type":"Punctuation","value":"("},
|
||||
{"type":"LiteralNumberInteger","value":"0"},
|
||||
{"type":"Punctuation","value":")"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"NameBuiltin","value":"vec4f"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Punctuation","value":"{"},
|
||||
{"type":"TextWhitespace","value":"\n "},
|
||||
{"type":"Keyword","value":"return"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"NameBuiltin","value":"vec4f"},
|
||||
{"type":"Punctuation","value":"("},
|
||||
{"type":"LiteralNumberFloat","value":"0.25"},
|
||||
{"type":"Punctuation","value":","},
|
||||
{"type":"LiteralNumberFloat","value":"0.25"},
|
||||
{"type":"Punctuation","value":","},
|
||||
{"type":"LiteralNumberFloat","value":"1.0"},
|
||||
{"type":"Punctuation","value":","},
|
||||
{"type":"LiteralNumberFloat","value":"1.0"},
|
||||
{"type":"Punctuation","value":");"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"Punctuation","value":"}"},
|
||||
{"type":"TextWhitespace","value":"\n"}
|
||||
]
|
Loading…
x
Reference in New Issue
Block a user