tint: Add builtin type aliases (vec3f, etc)

Fixed: tint:1772
Change-Id: I4bed36ded91ca5288875ed6ea819ff4bbb432186
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/112340
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
This commit is contained in:
Ben Clayton
2022-12-01 13:41:56 +00:00
committed by Dawn LUCI CQ
parent 5798f2d021
commit d5d207ba9f
74 changed files with 943 additions and 18 deletions

View File

@@ -93,15 +93,26 @@ func (l *lexer) lex() error {
case l.match("/", tok.Divide):
case l.match(".", tok.Dot):
case l.match("->", tok.Arrow):
case l.match("fn", tok.Function):
case l.match("op", tok.Operator):
case l.match("enum", tok.Enum):
case l.match("type", tok.Type):
case l.match("init", tok.Initializer):
case l.match("conv", tok.Converter):
case l.match("match", tok.Match):
case unicode.IsLetter(l.peek(0)) || l.peek(0) == '_':
l.tok(l.count(alphaNumericOrUnderscore), tok.Identifier)
n := l.count(alphaNumericOrUnderscore)
switch string(l.runes[:n]) {
case "fn":
l.tok(n, tok.Function)
case "op":
l.tok(n, tok.Operator)
case "enum":
l.tok(n, tok.Enum)
case "type":
l.tok(n, tok.Type)
case "init":
l.tok(n, tok.Initializer)
case "conv":
l.tok(n, tok.Converter)
case "match":
l.tok(n, tok.Match)
default:
l.tok(n, tok.Identifier)
}
case unicode.IsNumber(l.peek(0)) || l.peek(0) == '-':
isFloat := false
isNegative := false

View File

@@ -84,6 +84,9 @@ func TestLexTokens(t *testing.T) {
{"op", []tok.Token{{Kind: tok.Operator, Runes: []rune("op"), Source: tok.Source{
S: loc(1, 1, 0), E: loc(1, 3, 2),
}}}},
{"operation", []tok.Token{{Kind: tok.Identifier, Runes: []rune("operation"), Source: tok.Source{
S: loc(1, 1, 0), E: loc(1, 10, 9),
}}}},
{"type", []tok.Token{{Kind: tok.Type, Runes: []rune("type"), Source: tok.Source{
S: loc(1, 1, 0), E: loc(1, 5, 4),
}}}},