Skip to content

Commit

Permalink
Remove deprected attr [[, fix nested array bracket
Browse files Browse the repository at this point in the history
  • Loading branch information
brendan-duncan committed Jul 16, 2024
1 parent ed6b5ed commit 6dca9e9
Show file tree
Hide file tree
Showing 10 changed files with 9 additions and 141 deletions.
27 changes: 0 additions & 27 deletions js/wgsl_parser.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions js/wgsl_scanner.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 0 additions & 40 deletions src/wgsl_parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1696,46 +1696,6 @@ export class WgslParser {
attributes.push(attr);
}

// Deprecated:
// attr_left (attribute comma)* attribute attr_right
while (this._match(TokenTypes.tokens.attr_left)) {
if (!this._check(TokenTypes.tokens.attr_right)) {
do {
const name = this._consume(
TokenTypes.attribute_name,
"Expected attribute name"
);
const attr = new AST.Attribute(name.toString(), null);
if (this._match(TokenTypes.tokens.paren_left)) {
// literal_or_ident
attr.value = [
this._consume(
TokenTypes.literal_or_ident,
"Expected attribute value"
).toString(),
];
if (this._check(TokenTypes.tokens.comma)) {
this._advance();
do {
const v = this._consume(
TokenTypes.literal_or_ident,
"Expected attribute value"
).toString();
attr.value.push(v);
} while (this._match(TokenTypes.tokens.comma));
}
this._consume(TokenTypes.tokens.paren_right, "Expected ')'");
}
attributes.push(attr);
} while (this._match(TokenTypes.tokens.comma));
}
// Consume ]]
this._consume(
TokenTypes.tokens.attr_right,
"Expected ']]' after attribute declarations"
);
}

if (attributes.length == 0) {
return null;
}
Expand Down
4 changes: 0 additions & 4 deletions src/wgsl_scanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,6 @@ export class TokenTypes {
and_and: new TokenType("and_and", TokenClass.token, "&&"),
arrow: new TokenType("arrow ", TokenClass.token, "->"),
attr: new TokenType("attr", TokenClass.token, "@"),
attr_left: new TokenType("attr_left", TokenClass.token, "[["),
attr_right: new TokenType("attr_right", TokenClass.token, "]]"),
forward_slash: new TokenType("forward_slash", TokenClass.token, "/"),
bang: new TokenType("bang", TokenClass.token, "!"),
bracket_left: new TokenType("bracket_left", TokenClass.token, "["),
Expand Down Expand Up @@ -361,8 +359,6 @@ export class TokenTypes {
"&": this.tokens.and,
"&&": this.tokens.and_and,
"->": this.tokens.arrow ,
"[[": this.tokens.attr_left,
"]]": this.tokens.attr_right,
"/": this.tokens.forward_slash,
"!": this.tokens.bang,
"[": this.tokens.bracket_left,
Expand Down
7 changes: 7 additions & 0 deletions test/tests/test_scanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,13 @@ group("Scanner", function () {
test.equals(tokens[7].type, TokenTypes.tokens.equal);
});

test("nested array", function (test) {
const scanner = new WgslScanner("foo[bar[0]]");
const tokens = scanner.scanTokens();
test.equals(tokens.length, 8);
test.equals(tokens[6].type, TokenTypes.tokens.bracket_right);
});

test("fn foo(a, b) -> d { return; }", function (test) {
const scanner = new WgslScanner(`fn foo(a, b) -> d {
// skip this comment
Expand Down
4 changes: 0 additions & 4 deletions types/wgsl_scanner.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,6 @@ export declare class TokenTypes {
and_and: TokenType;
arrow: TokenType;
attr: TokenType;
attr_left: TokenType;
attr_right: TokenType;
forward_slash: TokenType;
bang: TokenType;
bracket_left: TokenType;
Expand Down Expand Up @@ -218,8 +216,6 @@ export declare class TokenTypes {
"&": TokenType;
"&&": TokenType;
"->": TokenType;
"[[": TokenType;
"]]": TokenType;
"/": TokenType;
"!": TokenType;
"[": TokenType;
Expand Down
31 changes: 0 additions & 31 deletions wgsl_reflect.module.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion wgsl_reflect.module.js.map

Large diffs are not rendered by default.

31 changes: 0 additions & 31 deletions wgsl_reflect.node.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion wgsl_reflect.node.js.map

Large diffs are not rendered by default.

0 comments on commit 6dca9e9

Please sign in to comment.