diff --git a/.gitignore b/.gitignore index 77d0e4c..819a96f 100644 --- a/.gitignore +++ b/.gitignore @@ -65,3 +65,4 @@ setup.py bindings/ src/* !src/scanner.c +!src/grammar.json diff --git a/grammar.js b/grammar.js index 1ade001..8197bf7 100644 --- a/grammar.js +++ b/grammar.js @@ -15,10 +15,10 @@ module.exports = grammar({ name: 'wgsl', externals: $ => [ - $._block_comment, + $.block_comment, $._disambiguate_template, - $._template_args_start, - $._template_args_end, + $.template_args_start, + $.template_args_end, $._less_than, $._less_than_equal, $._shift_left, @@ -31,14 +31,13 @@ module.exports = grammar({ ], extras: $ => [ - $._comment, - $._block_comment, + $.line_comment, + $.block_comment, $._blankspace, ], inline: $ => [ $.global_decl, - $._reserved, ], // WGSL has no parsing conflicts. @@ -81,7 +80,7 @@ module.exports = grammar({ diagnostic_rule_name: $ => choice($.diagnostic_name_token, seq($.diagnostic_name_token, '.', $.diagnostic_name_token)), - template_list: $ => seq($._template_args_start, $.template_arg_comma_list, $._template_args_end), + template_list: $ => seq($.template_args_start, $.template_arg_comma_list, $.template_args_end), template_arg_comma_list: $ => seq($.template_arg_expression, repeat(seq(',', $.template_arg_expression)), optional(',')), @@ -183,9 +182,11 @@ module.exports = grammar({ additive_operator: $ => choice('+', '-'), - shift_expression: $ => choice($.additive_expression, seq($.unary_expression, $._shift_left, $.unary_expression), seq($.unary_expression, $._shift_right, $.unary_expression)), + shift_expression: $ => choice($.additive_expression, seq($.unary_expression, $.shift_operator, $.unary_expression)), - relational_expression: $ => choice($.shift_expression, seq($.shift_expression, $._less_than, $.shift_expression), seq($.shift_expression, $._greater_than, $.shift_expression), seq($.shift_expression, $._less_than_equal, $.shift_expression), seq($.shift_expression, $._greater_than_equal, $.shift_expression), seq($.shift_expression, '==', $.shift_expression), seq($.shift_expression, '!=', $.shift_expression)), + shift_operator: $ => choice($._shift_left, $._shift_right), + + relational_expression: $ => choice($.shift_expression, seq($.shift_expression, $.comparison_operator, $.shift_expression)), short_circuit_and_expression: $ => choice($.relational_expression, seq($.short_circuit_and_expression, '&&', $.relational_expression)), @@ -207,6 +208,8 @@ module.exports = grammar({ compound_assignment_operator: $ => choice('+=', '-=', '*=', '/=', '%=', '&=', '|=', '^=', $._shift_right_assign, $._shift_left_assign), + comparison_operator: $ => choice('==', '!=', $._less_than, $._less_than_equal, $._greater_than, $._greater_than_equal), + increment_statement: $ => seq($.lhs_expression, '++'), decrement_statement: $ => seq($.lhs_expression, '--'), @@ -269,7 +272,7 @@ module.exports = grammar({ function_decl: $ => seq(repeat($.attribute), $.function_header, $.compound_statement), - function_header: $ => seq('fn', $.ident, '(', optional($.param_list), ')', optional(seq('->', repeat($.attribute), $.template_elaborated_ident))), + function_header: $ => seq('fn', $.ident, '(', optional($.param_list), ')', optional(seq('->', repeat($.attribute), $.type_specifier))), param_list: $ => seq($.param, repeat(seq(',', $.param)), optional(',')), @@ -295,8 +298,10 @@ module.exports = grammar({ ident: $ => seq($.ident_pattern_token, $._disambiguate_template), - _comment: $ => /\/\/.*/, + line_comment: $ => /\/\/.*/, + + _blankspace: $ => /[\u0020\u0009\u000a\u000b\u000c\u000d\u0085\u200e\u200f\u2028\u2029]/u, - _blankspace: $ => /[\u0020\u0009\u000a\u000b\u000c\u000d\u0085\u200e\u200f\u2028\u2029]/u + reserved: $ => choice('NULL', 'Self', 'abstract', 'active', 'alignas', 'alignof', 'as', 'asm', 'asm_fragment', 'async', 'attribute', 'auto', 'await', 'become', 'cast', 'catch', 'class', 'co_await', 'co_return', 'co_yield', 'coherent', 'column_major', 'common', 'compile', 'compile_fragment', 'concept', 'const_cast', 'consteval', 'constexpr', 'constinit', 'crate', 'debugger', 'decltype', 'delete', 'demote', 'demote_to_helper', 'do', 'dynamic_cast', 'enum', 'explicit', 'export', 'extends', 'extern', 'external', 'fallthrough', 'filter', 'final', 'finally', 'friend', 'from', 'fxgroup', 'get', 'goto', 'groupshared', 'highp', 'impl', 'implements', 'import', 'inline', 'instanceof', 'interface', 'layout', 'lowp', 'macro', 'macro_rules', 'match', 'mediump', 'meta', 'mod', 'module', 'move', 'mut', 'mutable', 'namespace', 'new', 'nil', 'noexcept', 'noinline', 'nointerpolation', 'non_coherent', 'noncoherent', 'noperspective', 'null', 'nullptr', 'of', 'operator', 'package', 'packoffset', 'partition', 'pass', 'patch', 'pixelfragment', 'precise', 'precision', 'premerge', 'priv', 'protected', 'pub', 'public', 'readonly', 'ref', 'regardless', 'register', 'reinterpret_cast', 'require', 'resource', 'restrict', 'self', 'set', 'shared', 'sizeof', 'smooth', 'snorm', 'static', 'static_assert', 'static_cast', 'std', 'subroutine', 'super', 'target', 'template', 'this', 'thread_local', 'throw', 'trait', 'try', 'type', 'typedef', 'typeid', 'typename', 'typeof', 'union', 'unless', 'unorm', 'unsafe', 'unsized', 'use', 'using', 'varying', 'virtual', 'volatile', 'wgsl', 'where', 'with', 'writeonly', 'yield'), } }) diff --git a/package.json b/package.json index 0bbc53f..074c748 100644 --- a/package.json +++ b/package.json @@ -52,6 +52,9 @@ ], "injection-regex": "^wgsl$", "highlights": "queries/highlights.scm" + "locals": "queries/locals.scm", + "folds": "queries/folds.scm", + "indents": "queries/indents/scm" } ] } diff --git a/queries/folds.scm b/queries/folds.scm new file mode 100644 index 0000000..7ff7868 --- /dev/null +++ b/queries/folds.scm @@ -0,0 +1,12 @@ +; Fold compound statements +[ + (compound_statement) + (continuing_compound_statement) + (switch_body) +] @fold + +; Fold struct declarations +(struct_body_decl) @fold + +; Fold function declarations +(function_decl) @fold diff --git a/queries/highlights.scm b/queries/highlights.scm index d9bc199..dd9fc15 100644 --- a/queries/highlights.scm +++ b/queries/highlights.scm @@ -1,78 +1,142 @@ -; Types -(type_specifier) @type -(template_elaborated_ident) @type +((ident) @variable + (#set! priority 99)) -; Functions -(function_decl - (function_header - (ident) @function)) -(call_expression - (call_phrase - (template_elaborated_ident) @function)) +(bool_literal) @boolean -; Variables and parameters -(param - (ident) @variable.parameter) -(variable_decl - (optionally_typed_ident (ident) @variable)) -(assert_statement) @variable +(int_literal) @number + +(float_literal) @number.float + +(line_comment) @comment + +(block_comment) @comment + +(type_specifier) @type -; Struct and struct members (struct_decl (ident) @type) -(struct_member - (member_ident) @property) -; Attributes +(type_alias_decl + (ident) @type) + +(template_arg_expression) @type + +(enable_extension_name) @module + +(language_extension_name) @module + +(severity_control_name) @constant + +(diagnostic_rule_name) @module + +(member_ident) @variable.member + +(component_or_swizzle_specifier) @variable.member + +(function_header + (ident) @function) + +(param + (ident)) @variable.parameter + +(call_expression + (call_phrase + (template_elaborated_ident + (ident) @function.call))) + +(func_call_statement + (call_phrase + (template_elaborated_ident + (ident) @function.call))) + (attribute) @attribute -; Literals -(bool_literal) @constant.builtin -(int_literal) @number -(float_literal) @float - -; Keywords and storage classes -(global_variable_decl - (variable_decl - (optionally_typed_ident - (ident) @variable))) - -; Control flow -"if" @keyword.control -"else" @keyword.control -"loop" @keyword.control -"for" @keyword.control -"while" @keyword.control -"switch" @keyword.control -"case" @keyword.control -"default" @keyword.control -"break" @keyword.control -"return" @keyword.control -"discard" @keyword.control - -; Declarations -(global_variable_decl) @keyword -(global_value_decl) @keyword -(variable_decl) @keyword - -; Punctuation -"(" @punctuation.bracket -")" @punctuation.bracket -"[" @punctuation.bracket -"]" @punctuation.bracket -"{" @punctuation.bracket -"}" @punctuation.bracket -"," @punctuation.delimiter -"." @punctuation.delimiter -":" @punctuation.delimiter -";" @punctuation.delimiter - -; Builtin functions and types -(builtin_value_name) @function.builtin - -; Additional keywords -"var" @keyword -"let" @keyword -"const" @keyword -"fn" @keyword -"struct" @keyword +[ + "const" + "const_assert" + "let" + "override" + "var" +] @keyword + +[ + "alias" + "struct" +] @keyword.type + +[ + "discard" + "return" +] @keyword.return + +"fn" @keyword.function + +[ + "diagnostic" + "enable" + "requires" +] @keyword.directive + +[ + "loop" + "for" + "while" + "continuing" + (break_statement) + (continue_statement) +] @keyword.repeat + +[ + "if" + "else" + "switch" + "case" + "default" +] @keyword.conditional + +[ + "+" + "-" + "*" + "/" + "%" + "=" + "&&" + "||" + "&" + "|" + "^" + "~" + "++" + "--" + "!" + (compound_assignment_operator) + (comparison_operator) + (shift_operator) +] @operator + +[ + "." + "," + ";" + ":" + "->" +] @punctuation.delimiter + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +[ + (template_args_start) + (template_args_end) +] @punctuation.special + +((ident) @keyword.modifier + (#match? @keyword.modifier + "^(function|private|workgroup|uniform|storage|read|write|read_write)$")) diff --git a/queries/indents.scm b/queries/indents.scm new file mode 100644 index 0000000..d5cee3b --- /dev/null +++ b/queries/indents.scm @@ -0,0 +1,35 @@ +; Indent blocks +(compound_statement) @indent.begin + +(compound_statement + "}" @indent.end) + +(continuing_compound_statement) @indent.begin + +(continuing_compound_statement + "}" @indent.end) + +(switch_body) @indent.begin + +(switch_body + "}" @indent.end) + +(struct_body_decl) @indent.begin + +(struct_body_decl + "}" @indent.end) + +(function_header) @indent.begin + +(function_header + ")" @indent.end) + +(argument_expression_list) @indent.begin + +(argument_expression_list + ")" @indent.end) + +[ + "}" + ")" +] @indent.branch diff --git a/queries/locals.scm b/queries/locals.scm new file mode 100644 index 0000000..d9a68ac --- /dev/null +++ b/queries/locals.scm @@ -0,0 +1,72 @@ +; Function bodies +(function_decl + (compound_statement) @local.scope) + +; All compound statements (if, while, for, blocks, etc.) +(compound_statement) @local.scope + +; For loops init/update +(for_statement) @local.scope + +; Switch bodies +(switch_body) @local.scope + +; Case clauses +(case_clause + (compound_statement) @local.scope) + +(default_alone_clause + (compound_statement) @local.scope) + +; Function definitions +(function_decl + (function_header + (ident) @local.definition.function)) + +; Function parameters +(param + (ident) @local.definition.parameter) + +; Variable declarations (var/let/const inside functions) +(variable_or_value_statement + (optionally_typed_ident + (ident) @local.definition.variable)) + +; Global variables +(global_variable_decl + (variable_decl + (optionally_typed_ident + (ident) @local.definition.variable))) + +; Global constants and overrides +(global_value_decl + (optionally_typed_ident + (ident) @local.definition.constant)) + +; Struct definitions +(struct_decl + (ident) @local.definition.type) + +; Struct members +(struct_member + (member_ident) @local.definition.field) + +; Type aliases +(type_alias_decl + (ident) @local.definition.type) + +; Identifiers in expressions +(template_elaborated_ident + (ident) @local.reference) + +; Member access (field references) +(member_ident) @local.reference + +; Type references in type specifiers +(type_specifier + (template_elaborated_ident + (ident) @local.reference)) + +(enable_extension_name) @local.reference + +(language_extension_name) @local.reference diff --git a/src/grammar.json b/src/grammar.json new file mode 100644 index 0000000..c84354b --- /dev/null +++ b/src/grammar.json @@ -0,0 +1,4121 @@ +{ + "$schema": "https://tree-sitter.github.io/tree-sitter/assets/schemas/grammar.schema.json", + "name": "wgsl", + "word": "ident_pattern_token", + "rules": { + "translation_unit": { + "type": "SEQ", + "members": [ + { + "type": "REPEAT", + "content": { + "type": "SYMBOL", + "name": "global_directive" + } + }, + { + "type": "REPEAT", + "content": { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "global_decl" + }, + { + "type": "SYMBOL", + "name": "global_assert" + }, + { + "type": "STRING", + "value": ";" + } + ] + } + } + ] + }, + "global_directive": { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "diagnostic_directive" + }, + { + "type": "SYMBOL", + "name": "enable_directive" + }, + { + "type": "SYMBOL", + "name": "requires_directive" + } + ] + }, + "global_decl": { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "global_variable_decl" + }, + { + "type": "STRING", + "value": ";" + } + ] + }, + { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "global_value_decl" + }, + { + "type": "STRING", + "value": ";" + } + ] + }, + { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "type_alias_decl" + }, + { + "type": "STRING", + "value": ";" + } + ] + }, + { + "type": "SYMBOL", + "name": "struct_decl" + }, + { + "type": "SYMBOL", + "name": "function_decl" + } + ] + }, + "bool_literal": { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "true" + }, + { + "type": "STRING", + "value": "false" + } + ] + }, + "int_literal": { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "decimal_int_literal" + }, + { + "type": "SYMBOL", + "name": "hex_int_literal" + } + ] + }, + "decimal_int_literal": { + "type": "CHOICE", + "members": [ + { + "type": "PATTERN", + "value": "0[iu]?" + }, + { + "type": "PATTERN", + "value": "[1-9][0-9]*[iu]?" + } + ] + }, + "hex_int_literal": { + "type": "PATTERN", + "value": "0[xX][0-9a-fA-F]+[iu]?" + }, + "float_literal": { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "decimal_float_literal" + }, + { + "type": "SYMBOL", + "name": "hex_float_literal" + } + ] + }, + "decimal_float_literal": { + "type": "CHOICE", + "members": [ + { + "type": "PATTERN", + "value": "0[fh]" + }, + { + "type": "PATTERN", + "value": "[1-9][0-9]*[fh]" + }, + { + "type": "PATTERN", + "value": "[0-9]*\\.[0-9]+([eE][+-]?[0-9]+)?[fh]?" + }, + { + "type": "PATTERN", + "value": "[0-9]+\\.[0-9]*([eE][+-]?[0-9]+)?[fh]?" + }, + { + "type": "PATTERN", + "value": "[0-9]+[eE][+-]?[0-9]+[fh]?" + } + ] + }, + "hex_float_literal": { + "type": "CHOICE", + "members": [ + { + "type": "PATTERN", + "value": "0[xX][0-9a-fA-F]*\\.[0-9a-fA-F]+([pP][+-]?[0-9]+[fh]?)?" + }, + { + "type": "PATTERN", + "value": "0[xX][0-9a-fA-F]+\\.[0-9a-fA-F]*([pP][+-]?[0-9]+[fh]?)?" + }, + { + "type": "PATTERN", + "value": "0[xX][0-9a-fA-F]+[pP][+-]?[0-9]+[fh]?" + } + ] + }, + "global_assert": { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "const_assert" + }, + { + "type": "STRING", + "value": ";" + } + ] + }, + "diagnostic_directive": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "diagnostic" + }, + { + "type": "SYMBOL", + "name": "diagnostic_control" + }, + { + "type": "STRING", + "value": ";" + } + ] + }, + "literal": { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "int_literal" + }, + { + "type": "SYMBOL", + "name": "float_literal" + }, + { + "type": "SYMBOL", + "name": "bool_literal" + } + ] + }, + "ident": { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "ident_pattern_token" + }, + { + "type": "SYMBOL", + "name": "_disambiguate_template" + } + ] + }, + "member_ident": { + "type": "SYMBOL", + "name": "ident_pattern_token" + }, + "diagnostic_name_token": { + "type": "SYMBOL", + "name": "ident_pattern_token" + }, + "diagnostic_rule_name": { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "diagnostic_name_token" + }, + { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "diagnostic_name_token" + }, + { + "type": "STRING", + "value": "." + }, + { + "type": "SYMBOL", + "name": "diagnostic_name_token" + } + ] + } + ] + }, + "template_list": { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "template_args_start" + }, + { + "type": "SYMBOL", + "name": "template_arg_comma_list" + }, + { + "type": "SYMBOL", + "name": "template_args_end" + } + ] + }, + "template_arg_comma_list": { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "template_arg_expression" + }, + { + "type": "REPEAT", + "content": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "SYMBOL", + "name": "template_arg_expression" + } + ] + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "BLANK" + } + ] + } + ] + }, + "template_arg_expression": { + "type": "SYMBOL", + "name": "expression" + }, + "align_attr": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "@" + }, + { + "type": "STRING", + "value": "align" + }, + { + "type": "STRING", + "value": "(" + }, + { + "type": "SYMBOL", + "name": "expression" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": ")" + } + ] + }, + "binding_attr": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "@" + }, + { + "type": "STRING", + "value": "binding" + }, + { + "type": "STRING", + "value": "(" + }, + { + "type": "SYMBOL", + "name": "expression" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": ")" + } + ] + }, + "blend_src_attr": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "@" + }, + { + "type": "STRING", + "value": "blend_src" + }, + { + "type": "STRING", + "value": "(" + }, + { + "type": "SYMBOL", + "name": "expression" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": ")" + } + ] + }, + "builtin_attr": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "@" + }, + { + "type": "STRING", + "value": "builtin" + }, + { + "type": "STRING", + "value": "(" + }, + { + "type": "SYMBOL", + "name": "builtin_value_name" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": ")" + } + ] + }, + "builtin_value_name": { + "type": "SYMBOL", + "name": "ident_pattern_token" + }, + "const_attr": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "@" + }, + { + "type": "STRING", + "value": "const" + } + ] + }, + "diagnostic_attr": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "@" + }, + { + "type": "STRING", + "value": "diagnostic" + }, + { + "type": "SYMBOL", + "name": "diagnostic_control" + } + ] + }, + "group_attr": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "@" + }, + { + "type": "STRING", + "value": "group" + }, + { + "type": "STRING", + "value": "(" + }, + { + "type": "SYMBOL", + "name": "expression" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": ")" + } + ] + }, + "id_attr": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "@" + }, + { + "type": "STRING", + "value": "id" + }, + { + "type": "STRING", + "value": "(" + }, + { + "type": "SYMBOL", + "name": "expression" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": ")" + } + ] + }, + "interpolate_attr": { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "@" + }, + { + "type": "STRING", + "value": "interpolate" + }, + { + "type": "STRING", + "value": "(" + }, + { + "type": "SYMBOL", + "name": "interpolate_type_name" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": ")" + } + ] + }, + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "@" + }, + { + "type": "STRING", + "value": "interpolate" + }, + { + "type": "STRING", + "value": "(" + }, + { + "type": "SYMBOL", + "name": "interpolate_type_name" + }, + { + "type": "STRING", + "value": "," + }, + { + "type": "SYMBOL", + "name": "interpolate_sampling_name" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": ")" + } + ] + } + ] + }, + "interpolate_type_name": { + "type": "SYMBOL", + "name": "ident_pattern_token" + }, + "interpolate_sampling_name": { + "type": "SYMBOL", + "name": "ident_pattern_token" + }, + "invariant_attr": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "@" + }, + { + "type": "STRING", + "value": "invariant" + } + ] + }, + "location_attr": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "@" + }, + { + "type": "STRING", + "value": "location" + }, + { + "type": "STRING", + "value": "(" + }, + { + "type": "SYMBOL", + "name": "expression" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": ")" + } + ] + }, + "must_use_attr": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "@" + }, + { + "type": "STRING", + "value": "must_use" + } + ] + }, + "size_attr": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "@" + }, + { + "type": "STRING", + "value": "size" + }, + { + "type": "STRING", + "value": "(" + }, + { + "type": "SYMBOL", + "name": "expression" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": ")" + } + ] + }, + "workgroup_size_attr": { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "@" + }, + { + "type": "STRING", + "value": "workgroup_size" + }, + { + "type": "STRING", + "value": "(" + }, + { + "type": "SYMBOL", + "name": "expression" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": ")" + } + ] + }, + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "@" + }, + { + "type": "STRING", + "value": "workgroup_size" + }, + { + "type": "STRING", + "value": "(" + }, + { + "type": "SYMBOL", + "name": "expression" + }, + { + "type": "STRING", + "value": "," + }, + { + "type": "SYMBOL", + "name": "expression" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": ")" + } + ] + }, + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "@" + }, + { + "type": "STRING", + "value": "workgroup_size" + }, + { + "type": "STRING", + "value": "(" + }, + { + "type": "SYMBOL", + "name": "expression" + }, + { + "type": "STRING", + "value": "," + }, + { + "type": "SYMBOL", + "name": "expression" + }, + { + "type": "STRING", + "value": "," + }, + { + "type": "SYMBOL", + "name": "expression" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": ")" + } + ] + } + ] + }, + "vertex_attr": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "@" + }, + { + "type": "STRING", + "value": "vertex" + } + ] + }, + "fragment_attr": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "@" + }, + { + "type": "STRING", + "value": "fragment" + } + ] + }, + "compute_attr": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "@" + }, + { + "type": "STRING", + "value": "compute" + } + ] + }, + "attribute": { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "@" + }, + { + "type": "SYMBOL", + "name": "ident_pattern_token" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "argument_expression_list" + }, + { + "type": "BLANK" + } + ] + } + ] + }, + { + "type": "SYMBOL", + "name": "align_attr" + }, + { + "type": "SYMBOL", + "name": "binding_attr" + }, + { + "type": "SYMBOL", + "name": "blend_src_attr" + }, + { + "type": "SYMBOL", + "name": "builtin_attr" + }, + { + "type": "SYMBOL", + "name": "const_attr" + }, + { + "type": "SYMBOL", + "name": "diagnostic_attr" + }, + { + "type": "SYMBOL", + "name": "group_attr" + }, + { + "type": "SYMBOL", + "name": "id_attr" + }, + { + "type": "SYMBOL", + "name": "interpolate_attr" + }, + { + "type": "SYMBOL", + "name": "invariant_attr" + }, + { + "type": "SYMBOL", + "name": "location_attr" + }, + { + "type": "SYMBOL", + "name": "must_use_attr" + }, + { + "type": "SYMBOL", + "name": "size_attr" + }, + { + "type": "SYMBOL", + "name": "workgroup_size_attr" + }, + { + "type": "SYMBOL", + "name": "vertex_attr" + }, + { + "type": "SYMBOL", + "name": "fragment_attr" + }, + { + "type": "SYMBOL", + "name": "compute_attr" + } + ] + }, + "diagnostic_control": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "(" + }, + { + "type": "SYMBOL", + "name": "severity_control_name" + }, + { + "type": "STRING", + "value": "," + }, + { + "type": "SYMBOL", + "name": "diagnostic_rule_name" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": ")" + } + ] + }, + "struct_decl": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "struct" + }, + { + "type": "SYMBOL", + "name": "ident" + }, + { + "type": "SYMBOL", + "name": "struct_body_decl" + } + ] + }, + "struct_body_decl": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "{" + }, + { + "type": "SYMBOL", + "name": "struct_member" + }, + { + "type": "REPEAT", + "content": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "SYMBOL", + "name": "struct_member" + } + ] + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": "}" + } + ] + }, + "struct_member": { + "type": "SEQ", + "members": [ + { + "type": "REPEAT", + "content": { + "type": "SYMBOL", + "name": "attribute" + } + }, + { + "type": "SYMBOL", + "name": "member_ident" + }, + { + "type": "STRING", + "value": ":" + }, + { + "type": "SYMBOL", + "name": "type_specifier" + } + ] + }, + "type_alias_decl": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "alias" + }, + { + "type": "SYMBOL", + "name": "ident" + }, + { + "type": "STRING", + "value": "=" + }, + { + "type": "SYMBOL", + "name": "type_specifier" + } + ] + }, + "type_specifier": { + "type": "SYMBOL", + "name": "template_elaborated_ident" + }, + "template_elaborated_ident": { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "ident" + }, + { + "type": "SYMBOL", + "name": "_disambiguate_template" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "template_list" + }, + { + "type": "BLANK" + } + ] + } + ] + }, + "variable_or_value_statement": { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "variable_decl" + }, + { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "variable_decl" + }, + { + "type": "STRING", + "value": "=" + }, + { + "type": "SYMBOL", + "name": "expression" + } + ] + }, + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "let" + }, + { + "type": "SYMBOL", + "name": "optionally_typed_ident" + }, + { + "type": "STRING", + "value": "=" + }, + { + "type": "SYMBOL", + "name": "expression" + } + ] + }, + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "const" + }, + { + "type": "SYMBOL", + "name": "optionally_typed_ident" + }, + { + "type": "STRING", + "value": "=" + }, + { + "type": "SYMBOL", + "name": "expression" + } + ] + } + ] + }, + "variable_decl": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "var" + }, + { + "type": "SYMBOL", + "name": "_disambiguate_template" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "template_list" + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "SYMBOL", + "name": "optionally_typed_ident" + } + ] + }, + "optionally_typed_ident": { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "ident" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": ":" + }, + { + "type": "SYMBOL", + "name": "type_specifier" + } + ] + }, + { + "type": "BLANK" + } + ] + } + ] + }, + "global_variable_decl": { + "type": "SEQ", + "members": [ + { + "type": "REPEAT", + "content": { + "type": "SYMBOL", + "name": "attribute" + } + }, + { + "type": "SYMBOL", + "name": "variable_decl" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "=" + }, + { + "type": "SYMBOL", + "name": "expression" + } + ] + }, + { + "type": "BLANK" + } + ] + } + ] + }, + "global_value_decl": { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "const" + }, + { + "type": "SYMBOL", + "name": "optionally_typed_ident" + }, + { + "type": "STRING", + "value": "=" + }, + { + "type": "SYMBOL", + "name": "expression" + } + ] + }, + { + "type": "SEQ", + "members": [ + { + "type": "REPEAT", + "content": { + "type": "SYMBOL", + "name": "attribute" + } + }, + { + "type": "STRING", + "value": "override" + }, + { + "type": "SYMBOL", + "name": "optionally_typed_ident" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "=" + }, + { + "type": "SYMBOL", + "name": "expression" + } + ] + }, + { + "type": "BLANK" + } + ] + } + ] + } + ] + }, + "primary_expression": { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "template_elaborated_ident" + }, + { + "type": "SYMBOL", + "name": "call_expression" + }, + { + "type": "SYMBOL", + "name": "literal" + }, + { + "type": "SYMBOL", + "name": "paren_expression" + } + ] + }, + "call_expression": { + "type": "SYMBOL", + "name": "call_phrase" + }, + "call_phrase": { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "template_elaborated_ident" + }, + { + "type": "SYMBOL", + "name": "argument_expression_list" + } + ] + }, + "paren_expression": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "(" + }, + { + "type": "SYMBOL", + "name": "expression" + }, + { + "type": "STRING", + "value": ")" + } + ] + }, + "argument_expression_list": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "(" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "expression_comma_list" + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": ")" + } + ] + }, + "expression_comma_list": { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "expression" + }, + { + "type": "REPEAT", + "content": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "SYMBOL", + "name": "expression" + } + ] + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "BLANK" + } + ] + } + ] + }, + "component_or_swizzle_specifier": { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "[" + }, + { + "type": "SYMBOL", + "name": "expression" + }, + { + "type": "STRING", + "value": "]" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "component_or_swizzle_specifier" + }, + { + "type": "BLANK" + } + ] + } + ] + }, + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "." + }, + { + "type": "SYMBOL", + "name": "member_ident" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "component_or_swizzle_specifier" + }, + { + "type": "BLANK" + } + ] + } + ] + }, + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "." + }, + { + "type": "SYMBOL", + "name": "swizzle_name" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "component_or_swizzle_specifier" + }, + { + "type": "BLANK" + } + ] + } + ] + } + ] + }, + "unary_expression": { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "singular_expression" + }, + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "-" + }, + { + "type": "SYMBOL", + "name": "unary_expression" + } + ] + }, + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "!" + }, + { + "type": "SYMBOL", + "name": "unary_expression" + } + ] + }, + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "~" + }, + { + "type": "SYMBOL", + "name": "unary_expression" + } + ] + }, + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "*" + }, + { + "type": "SYMBOL", + "name": "unary_expression" + } + ] + }, + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "&" + }, + { + "type": "SYMBOL", + "name": "unary_expression" + } + ] + } + ] + }, + "singular_expression": { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "primary_expression" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "component_or_swizzle_specifier" + }, + { + "type": "BLANK" + } + ] + } + ] + }, + "lhs_expression": { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "core_lhs_expression" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "component_or_swizzle_specifier" + }, + { + "type": "BLANK" + } + ] + } + ] + }, + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "*" + }, + { + "type": "SYMBOL", + "name": "lhs_expression" + } + ] + }, + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "&" + }, + { + "type": "SYMBOL", + "name": "lhs_expression" + } + ] + } + ] + }, + "core_lhs_expression": { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "ident" + }, + { + "type": "SYMBOL", + "name": "_disambiguate_template" + } + ] + }, + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "(" + }, + { + "type": "SYMBOL", + "name": "lhs_expression" + }, + { + "type": "STRING", + "value": ")" + } + ] + } + ] + }, + "multiplicative_expression": { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "unary_expression" + }, + { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "multiplicative_expression" + }, + { + "type": "SYMBOL", + "name": "multiplicative_operator" + }, + { + "type": "SYMBOL", + "name": "unary_expression" + } + ] + } + ] + }, + "multiplicative_operator": { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "*" + }, + { + "type": "STRING", + "value": "/" + }, + { + "type": "STRING", + "value": "%" + } + ] + }, + "additive_expression": { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "multiplicative_expression" + }, + { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "additive_expression" + }, + { + "type": "SYMBOL", + "name": "additive_operator" + }, + { + "type": "SYMBOL", + "name": "multiplicative_expression" + } + ] + } + ] + }, + "additive_operator": { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "+" + }, + { + "type": "STRING", + "value": "-" + } + ] + }, + "shift_expression": { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "additive_expression" + }, + { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "unary_expression" + }, + { + "type": "SYMBOL", + "name": "shift_operator" + }, + { + "type": "SYMBOL", + "name": "unary_expression" + } + ] + } + ] + }, + "shift_operator": { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "_shift_left" + }, + { + "type": "SYMBOL", + "name": "_shift_right" + } + ] + }, + "relational_expression": { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "shift_expression" + }, + { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "shift_expression" + }, + { + "type": "SYMBOL", + "name": "comparison_operator" + }, + { + "type": "SYMBOL", + "name": "shift_expression" + } + ] + } + ] + }, + "short_circuit_and_expression": { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "relational_expression" + }, + { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "short_circuit_and_expression" + }, + { + "type": "STRING", + "value": "&&" + }, + { + "type": "SYMBOL", + "name": "relational_expression" + } + ] + } + ] + }, + "short_circuit_or_expression": { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "relational_expression" + }, + { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "short_circuit_or_expression" + }, + { + "type": "STRING", + "value": "||" + }, + { + "type": "SYMBOL", + "name": "relational_expression" + } + ] + } + ] + }, + "binary_or_expression": { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "unary_expression" + }, + { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "binary_or_expression" + }, + { + "type": "STRING", + "value": "|" + }, + { + "type": "SYMBOL", + "name": "unary_expression" + } + ] + } + ] + }, + "binary_and_expression": { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "unary_expression" + }, + { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "binary_and_expression" + }, + { + "type": "STRING", + "value": "&" + }, + { + "type": "SYMBOL", + "name": "unary_expression" + } + ] + } + ] + }, + "binary_xor_expression": { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "unary_expression" + }, + { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "binary_xor_expression" + }, + { + "type": "STRING", + "value": "^" + }, + { + "type": "SYMBOL", + "name": "unary_expression" + } + ] + } + ] + }, + "bitwise_expression": { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "binary_and_expression" + }, + { + "type": "STRING", + "value": "&" + }, + { + "type": "SYMBOL", + "name": "unary_expression" + } + ] + }, + { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "binary_or_expression" + }, + { + "type": "STRING", + "value": "|" + }, + { + "type": "SYMBOL", + "name": "unary_expression" + } + ] + }, + { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "binary_xor_expression" + }, + { + "type": "STRING", + "value": "^" + }, + { + "type": "SYMBOL", + "name": "unary_expression" + } + ] + } + ] + }, + "expression": { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "relational_expression" + }, + { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "short_circuit_or_expression" + }, + { + "type": "STRING", + "value": "||" + }, + { + "type": "SYMBOL", + "name": "relational_expression" + } + ] + }, + { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "short_circuit_and_expression" + }, + { + "type": "STRING", + "value": "&&" + }, + { + "type": "SYMBOL", + "name": "relational_expression" + } + ] + }, + { + "type": "SYMBOL", + "name": "bitwise_expression" + } + ] + }, + "compound_statement": { + "type": "SEQ", + "members": [ + { + "type": "REPEAT", + "content": { + "type": "SYMBOL", + "name": "attribute" + } + }, + { + "type": "STRING", + "value": "{" + }, + { + "type": "REPEAT", + "content": { + "type": "SYMBOL", + "name": "statement" + } + }, + { + "type": "STRING", + "value": "}" + } + ] + }, + "assignment_statement": { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "lhs_expression" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "=" + }, + { + "type": "SYMBOL", + "name": "compound_assignment_operator" + } + ] + }, + { + "type": "SYMBOL", + "name": "expression" + } + ] + }, + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "_" + }, + { + "type": "STRING", + "value": "=" + }, + { + "type": "SYMBOL", + "name": "expression" + } + ] + } + ] + }, + "compound_assignment_operator": { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "+=" + }, + { + "type": "STRING", + "value": "-=" + }, + { + "type": "STRING", + "value": "*=" + }, + { + "type": "STRING", + "value": "/=" + }, + { + "type": "STRING", + "value": "%=" + }, + { + "type": "STRING", + "value": "&=" + }, + { + "type": "STRING", + "value": "|=" + }, + { + "type": "STRING", + "value": "^=" + }, + { + "type": "SYMBOL", + "name": "_shift_right_assign" + }, + { + "type": "SYMBOL", + "name": "_shift_left_assign" + } + ] + }, + "comparison_operator": { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "==" + }, + { + "type": "STRING", + "value": "!=" + }, + { + "type": "SYMBOL", + "name": "_less_than" + }, + { + "type": "SYMBOL", + "name": "_less_than_equal" + }, + { + "type": "SYMBOL", + "name": "_greater_than" + }, + { + "type": "SYMBOL", + "name": "_greater_than_equal" + } + ] + }, + "increment_statement": { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "lhs_expression" + }, + { + "type": "STRING", + "value": "++" + } + ] + }, + "decrement_statement": { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "lhs_expression" + }, + { + "type": "STRING", + "value": "--" + } + ] + }, + "if_statement": { + "type": "SEQ", + "members": [ + { + "type": "REPEAT", + "content": { + "type": "SYMBOL", + "name": "attribute" + } + }, + { + "type": "SYMBOL", + "name": "if_clause" + }, + { + "type": "REPEAT", + "content": { + "type": "SYMBOL", + "name": "else_if_clause" + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "else_clause" + }, + { + "type": "BLANK" + } + ] + } + ] + }, + "if_clause": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "if" + }, + { + "type": "SYMBOL", + "name": "expression" + }, + { + "type": "SYMBOL", + "name": "compound_statement" + } + ] + }, + "else_if_clause": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "else" + }, + { + "type": "STRING", + "value": "if" + }, + { + "type": "SYMBOL", + "name": "expression" + }, + { + "type": "SYMBOL", + "name": "compound_statement" + } + ] + }, + "else_clause": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "else" + }, + { + "type": "SYMBOL", + "name": "compound_statement" + } + ] + }, + "switch_statement": { + "type": "SEQ", + "members": [ + { + "type": "REPEAT", + "content": { + "type": "SYMBOL", + "name": "attribute" + } + }, + { + "type": "STRING", + "value": "switch" + }, + { + "type": "SYMBOL", + "name": "expression" + }, + { + "type": "SYMBOL", + "name": "switch_body" + } + ] + }, + "switch_body": { + "type": "SEQ", + "members": [ + { + "type": "REPEAT", + "content": { + "type": "SYMBOL", + "name": "attribute" + } + }, + { + "type": "STRING", + "value": "{" + }, + { + "type": "REPEAT1", + "content": { + "type": "SYMBOL", + "name": "switch_clause" + } + }, + { + "type": "STRING", + "value": "}" + } + ] + }, + "switch_clause": { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "case_clause" + }, + { + "type": "SYMBOL", + "name": "default_alone_clause" + } + ] + }, + "case_clause": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "case" + }, + { + "type": "SYMBOL", + "name": "case_selectors" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": ":" + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "SYMBOL", + "name": "compound_statement" + } + ] + }, + "default_alone_clause": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "default" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": ":" + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "SYMBOL", + "name": "compound_statement" + } + ] + }, + "case_selectors": { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "case_selector" + }, + { + "type": "REPEAT", + "content": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "SYMBOL", + "name": "case_selector" + } + ] + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "BLANK" + } + ] + } + ] + }, + "case_selector": { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "default" + }, + { + "type": "SYMBOL", + "name": "expression" + } + ] + }, + "loop_statement": { + "type": "SEQ", + "members": [ + { + "type": "REPEAT", + "content": { + "type": "SYMBOL", + "name": "attribute" + } + }, + { + "type": "STRING", + "value": "loop" + }, + { + "type": "REPEAT", + "content": { + "type": "SYMBOL", + "name": "attribute" + } + }, + { + "type": "STRING", + "value": "{" + }, + { + "type": "REPEAT", + "content": { + "type": "SYMBOL", + "name": "statement" + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "continuing_statement" + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": "}" + } + ] + }, + "for_statement": { + "type": "SEQ", + "members": [ + { + "type": "REPEAT", + "content": { + "type": "SYMBOL", + "name": "attribute" + } + }, + { + "type": "STRING", + "value": "for" + }, + { + "type": "STRING", + "value": "(" + }, + { + "type": "SYMBOL", + "name": "for_header" + }, + { + "type": "STRING", + "value": ")" + }, + { + "type": "SYMBOL", + "name": "compound_statement" + } + ] + }, + "for_header": { + "type": "SEQ", + "members": [ + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "for_init" + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": ";" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "expression" + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": ";" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "for_update" + }, + { + "type": "BLANK" + } + ] + } + ] + }, + "for_init": { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "variable_or_value_statement" + }, + { + "type": "SYMBOL", + "name": "variable_updating_statement" + }, + { + "type": "SYMBOL", + "name": "func_call_statement" + } + ] + }, + "for_update": { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "variable_updating_statement" + }, + { + "type": "SYMBOL", + "name": "func_call_statement" + } + ] + }, + "while_statement": { + "type": "SEQ", + "members": [ + { + "type": "REPEAT", + "content": { + "type": "SYMBOL", + "name": "attribute" + } + }, + { + "type": "STRING", + "value": "while" + }, + { + "type": "SYMBOL", + "name": "expression" + }, + { + "type": "SYMBOL", + "name": "compound_statement" + } + ] + }, + "break_statement": { + "type": "STRING", + "value": "break" + }, + "break_if_statement": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "break" + }, + { + "type": "STRING", + "value": "if" + }, + { + "type": "SYMBOL", + "name": "expression" + }, + { + "type": "STRING", + "value": ";" + } + ] + }, + "continue_statement": { + "type": "STRING", + "value": "continue" + }, + "continuing_statement": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "continuing" + }, + { + "type": "SYMBOL", + "name": "continuing_compound_statement" + } + ] + }, + "continuing_compound_statement": { + "type": "SEQ", + "members": [ + { + "type": "REPEAT", + "content": { + "type": "SYMBOL", + "name": "attribute" + } + }, + { + "type": "STRING", + "value": "{" + }, + { + "type": "REPEAT", + "content": { + "type": "SYMBOL", + "name": "statement" + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "break_if_statement" + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": "}" + } + ] + }, + "return_statement": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "return" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "expression" + }, + { + "type": "BLANK" + } + ] + } + ] + }, + "func_call_statement": { + "type": "SYMBOL", + "name": "call_phrase" + }, + "const_assert": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "const_assert" + }, + { + "type": "SYMBOL", + "name": "expression" + } + ] + }, + "assert_statement": { + "type": "SYMBOL", + "name": "const_assert" + }, + "statement": { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": ";" + }, + { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "return_statement" + }, + { + "type": "STRING", + "value": ";" + } + ] + }, + { + "type": "SYMBOL", + "name": "if_statement" + }, + { + "type": "SYMBOL", + "name": "switch_statement" + }, + { + "type": "SYMBOL", + "name": "loop_statement" + }, + { + "type": "SYMBOL", + "name": "for_statement" + }, + { + "type": "SYMBOL", + "name": "while_statement" + }, + { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "func_call_statement" + }, + { + "type": "STRING", + "value": ";" + } + ] + }, + { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "variable_or_value_statement" + }, + { + "type": "STRING", + "value": ";" + } + ] + }, + { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "break_statement" + }, + { + "type": "STRING", + "value": ";" + } + ] + }, + { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "continue_statement" + }, + { + "type": "STRING", + "value": ";" + } + ] + }, + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "discard" + }, + { + "type": "STRING", + "value": ";" + } + ] + }, + { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "variable_updating_statement" + }, + { + "type": "STRING", + "value": ";" + } + ] + }, + { + "type": "SYMBOL", + "name": "compound_statement" + }, + { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "assert_statement" + }, + { + "type": "STRING", + "value": ";" + } + ] + } + ] + }, + "variable_updating_statement": { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "assignment_statement" + }, + { + "type": "SYMBOL", + "name": "increment_statement" + }, + { + "type": "SYMBOL", + "name": "decrement_statement" + } + ] + }, + "function_decl": { + "type": "SEQ", + "members": [ + { + "type": "REPEAT", + "content": { + "type": "SYMBOL", + "name": "attribute" + } + }, + { + "type": "SYMBOL", + "name": "function_header" + }, + { + "type": "SYMBOL", + "name": "compound_statement" + } + ] + }, + "function_header": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "fn" + }, + { + "type": "SYMBOL", + "name": "ident" + }, + { + "type": "STRING", + "value": "(" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "param_list" + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": ")" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "->" + }, + { + "type": "REPEAT", + "content": { + "type": "SYMBOL", + "name": "attribute" + } + }, + { + "type": "SYMBOL", + "name": "type_specifier" + } + ] + }, + { + "type": "BLANK" + } + ] + } + ] + }, + "param_list": { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "param" + }, + { + "type": "REPEAT", + "content": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "SYMBOL", + "name": "param" + } + ] + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "BLANK" + } + ] + } + ] + }, + "param": { + "type": "SEQ", + "members": [ + { + "type": "REPEAT", + "content": { + "type": "SYMBOL", + "name": "attribute" + } + }, + { + "type": "SYMBOL", + "name": "ident" + }, + { + "type": "STRING", + "value": ":" + }, + { + "type": "SYMBOL", + "name": "type_specifier" + } + ] + }, + "enable_directive": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "enable" + }, + { + "type": "SYMBOL", + "name": "enable_extension_list" + }, + { + "type": "STRING", + "value": ";" + } + ] + }, + "enable_extension_list": { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "enable_extension_name" + }, + { + "type": "REPEAT", + "content": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "SYMBOL", + "name": "enable_extension_name" + } + ] + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "BLANK" + } + ] + } + ] + }, + "requires_directive": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "requires" + }, + { + "type": "SYMBOL", + "name": "language_extension_list" + }, + { + "type": "STRING", + "value": ";" + } + ] + }, + "language_extension_list": { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "language_extension_name" + }, + { + "type": "REPEAT", + "content": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "SYMBOL", + "name": "language_extension_name" + } + ] + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "BLANK" + } + ] + } + ] + }, + "enable_extension_name": { + "type": "SYMBOL", + "name": "ident_pattern_token" + }, + "language_extension_name": { + "type": "SYMBOL", + "name": "ident_pattern_token" + }, + "ident_pattern_token": { + "type": "PATTERN", + "value": "([_\\p{XID_Start}][\\p{XID_Continue}]+)|([\\p{XID_Start}])", + "flags": "u" + }, + "severity_control_name": { + "type": "SYMBOL", + "name": "ident_pattern_token" + }, + "swizzle_name": { + "type": "CHOICE", + "members": [ + { + "type": "PATTERN", + "value": "[rgba]" + }, + { + "type": "PATTERN", + "value": "[rgba][rgba]" + }, + { + "type": "PATTERN", + "value": "[rgba][rgba][rgba]" + }, + { + "type": "PATTERN", + "value": "[rgba][rgba][rgba][rgba]" + }, + { + "type": "PATTERN", + "value": "[xyzw]" + }, + { + "type": "PATTERN", + "value": "[xyzw][xyzw]" + }, + { + "type": "PATTERN", + "value": "[xyzw][xyzw][xyzw]" + }, + { + "type": "PATTERN", + "value": "[xyzw][xyzw][xyzw][xyzw]" + } + ] + }, + "line_comment": { + "type": "PATTERN", + "value": "\\/\\/.*" + }, + "_blankspace": { + "type": "PATTERN", + "value": "[\\u0020\\u0009\\u000a\\u000b\\u000c\\u000d\\u0085\\u200e\\u200f\\u2028\\u2029]", + "flags": "u" + }, + "reserved": { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "NULL" + }, + { + "type": "STRING", + "value": "Self" + }, + { + "type": "STRING", + "value": "abstract" + }, + { + "type": "STRING", + "value": "active" + }, + { + "type": "STRING", + "value": "alignas" + }, + { + "type": "STRING", + "value": "alignof" + }, + { + "type": "STRING", + "value": "as" + }, + { + "type": "STRING", + "value": "asm" + }, + { + "type": "STRING", + "value": "asm_fragment" + }, + { + "type": "STRING", + "value": "async" + }, + { + "type": "STRING", + "value": "attribute" + }, + { + "type": "STRING", + "value": "auto" + }, + { + "type": "STRING", + "value": "await" + }, + { + "type": "STRING", + "value": "become" + }, + { + "type": "STRING", + "value": "cast" + }, + { + "type": "STRING", + "value": "catch" + }, + { + "type": "STRING", + "value": "class" + }, + { + "type": "STRING", + "value": "co_await" + }, + { + "type": "STRING", + "value": "co_return" + }, + { + "type": "STRING", + "value": "co_yield" + }, + { + "type": "STRING", + "value": "coherent" + }, + { + "type": "STRING", + "value": "column_major" + }, + { + "type": "STRING", + "value": "common" + }, + { + "type": "STRING", + "value": "compile" + }, + { + "type": "STRING", + "value": "compile_fragment" + }, + { + "type": "STRING", + "value": "concept" + }, + { + "type": "STRING", + "value": "const_cast" + }, + { + "type": "STRING", + "value": "consteval" + }, + { + "type": "STRING", + "value": "constexpr" + }, + { + "type": "STRING", + "value": "constinit" + }, + { + "type": "STRING", + "value": "crate" + }, + { + "type": "STRING", + "value": "debugger" + }, + { + "type": "STRING", + "value": "decltype" + }, + { + "type": "STRING", + "value": "delete" + }, + { + "type": "STRING", + "value": "demote" + }, + { + "type": "STRING", + "value": "demote_to_helper" + }, + { + "type": "STRING", + "value": "do" + }, + { + "type": "STRING", + "value": "dynamic_cast" + }, + { + "type": "STRING", + "value": "enum" + }, + { + "type": "STRING", + "value": "explicit" + }, + { + "type": "STRING", + "value": "export" + }, + { + "type": "STRING", + "value": "extends" + }, + { + "type": "STRING", + "value": "extern" + }, + { + "type": "STRING", + "value": "external" + }, + { + "type": "STRING", + "value": "fallthrough" + }, + { + "type": "STRING", + "value": "filter" + }, + { + "type": "STRING", + "value": "final" + }, + { + "type": "STRING", + "value": "finally" + }, + { + "type": "STRING", + "value": "friend" + }, + { + "type": "STRING", + "value": "from" + }, + { + "type": "STRING", + "value": "fxgroup" + }, + { + "type": "STRING", + "value": "get" + }, + { + "type": "STRING", + "value": "goto" + }, + { + "type": "STRING", + "value": "groupshared" + }, + { + "type": "STRING", + "value": "highp" + }, + { + "type": "STRING", + "value": "impl" + }, + { + "type": "STRING", + "value": "implements" + }, + { + "type": "STRING", + "value": "import" + }, + { + "type": "STRING", + "value": "inline" + }, + { + "type": "STRING", + "value": "instanceof" + }, + { + "type": "STRING", + "value": "interface" + }, + { + "type": "STRING", + "value": "layout" + }, + { + "type": "STRING", + "value": "lowp" + }, + { + "type": "STRING", + "value": "macro" + }, + { + "type": "STRING", + "value": "macro_rules" + }, + { + "type": "STRING", + "value": "match" + }, + { + "type": "STRING", + "value": "mediump" + }, + { + "type": "STRING", + "value": "meta" + }, + { + "type": "STRING", + "value": "mod" + }, + { + "type": "STRING", + "value": "module" + }, + { + "type": "STRING", + "value": "move" + }, + { + "type": "STRING", + "value": "mut" + }, + { + "type": "STRING", + "value": "mutable" + }, + { + "type": "STRING", + "value": "namespace" + }, + { + "type": "STRING", + "value": "new" + }, + { + "type": "STRING", + "value": "nil" + }, + { + "type": "STRING", + "value": "noexcept" + }, + { + "type": "STRING", + "value": "noinline" + }, + { + "type": "STRING", + "value": "nointerpolation" + }, + { + "type": "STRING", + "value": "non_coherent" + }, + { + "type": "STRING", + "value": "noncoherent" + }, + { + "type": "STRING", + "value": "noperspective" + }, + { + "type": "STRING", + "value": "null" + }, + { + "type": "STRING", + "value": "nullptr" + }, + { + "type": "STRING", + "value": "of" + }, + { + "type": "STRING", + "value": "operator" + }, + { + "type": "STRING", + "value": "package" + }, + { + "type": "STRING", + "value": "packoffset" + }, + { + "type": "STRING", + "value": "partition" + }, + { + "type": "STRING", + "value": "pass" + }, + { + "type": "STRING", + "value": "patch" + }, + { + "type": "STRING", + "value": "pixelfragment" + }, + { + "type": "STRING", + "value": "precise" + }, + { + "type": "STRING", + "value": "precision" + }, + { + "type": "STRING", + "value": "premerge" + }, + { + "type": "STRING", + "value": "priv" + }, + { + "type": "STRING", + "value": "protected" + }, + { + "type": "STRING", + "value": "pub" + }, + { + "type": "STRING", + "value": "public" + }, + { + "type": "STRING", + "value": "readonly" + }, + { + "type": "STRING", + "value": "ref" + }, + { + "type": "STRING", + "value": "regardless" + }, + { + "type": "STRING", + "value": "register" + }, + { + "type": "STRING", + "value": "reinterpret_cast" + }, + { + "type": "STRING", + "value": "require" + }, + { + "type": "STRING", + "value": "resource" + }, + { + "type": "STRING", + "value": "restrict" + }, + { + "type": "STRING", + "value": "self" + }, + { + "type": "STRING", + "value": "set" + }, + { + "type": "STRING", + "value": "shared" + }, + { + "type": "STRING", + "value": "sizeof" + }, + { + "type": "STRING", + "value": "smooth" + }, + { + "type": "STRING", + "value": "snorm" + }, + { + "type": "STRING", + "value": "static" + }, + { + "type": "STRING", + "value": "static_assert" + }, + { + "type": "STRING", + "value": "static_cast" + }, + { + "type": "STRING", + "value": "std" + }, + { + "type": "STRING", + "value": "subroutine" + }, + { + "type": "STRING", + "value": "super" + }, + { + "type": "STRING", + "value": "target" + }, + { + "type": "STRING", + "value": "template" + }, + { + "type": "STRING", + "value": "this" + }, + { + "type": "STRING", + "value": "thread_local" + }, + { + "type": "STRING", + "value": "throw" + }, + { + "type": "STRING", + "value": "trait" + }, + { + "type": "STRING", + "value": "try" + }, + { + "type": "STRING", + "value": "type" + }, + { + "type": "STRING", + "value": "typedef" + }, + { + "type": "STRING", + "value": "typeid" + }, + { + "type": "STRING", + "value": "typename" + }, + { + "type": "STRING", + "value": "typeof" + }, + { + "type": "STRING", + "value": "union" + }, + { + "type": "STRING", + "value": "unless" + }, + { + "type": "STRING", + "value": "unorm" + }, + { + "type": "STRING", + "value": "unsafe" + }, + { + "type": "STRING", + "value": "unsized" + }, + { + "type": "STRING", + "value": "use" + }, + { + "type": "STRING", + "value": "using" + }, + { + "type": "STRING", + "value": "varying" + }, + { + "type": "STRING", + "value": "virtual" + }, + { + "type": "STRING", + "value": "volatile" + }, + { + "type": "STRING", + "value": "wgsl" + }, + { + "type": "STRING", + "value": "where" + }, + { + "type": "STRING", + "value": "with" + }, + { + "type": "STRING", + "value": "writeonly" + }, + { + "type": "STRING", + "value": "yield" + } + ] + } + }, + "extras": [ + { + "type": "SYMBOL", + "name": "line_comment" + }, + { + "type": "SYMBOL", + "name": "block_comment" + }, + { + "type": "SYMBOL", + "name": "_blankspace" + } + ], + "conflicts": [], + "precedences": [], + "externals": [ + { + "type": "SYMBOL", + "name": "block_comment" + }, + { + "type": "SYMBOL", + "name": "_disambiguate_template" + }, + { + "type": "SYMBOL", + "name": "template_args_start" + }, + { + "type": "SYMBOL", + "name": "template_args_end" + }, + { + "type": "SYMBOL", + "name": "_less_than" + }, + { + "type": "SYMBOL", + "name": "_less_than_equal" + }, + { + "type": "SYMBOL", + "name": "_shift_left" + }, + { + "type": "SYMBOL", + "name": "_shift_left_assign" + }, + { + "type": "SYMBOL", + "name": "_greater_than" + }, + { + "type": "SYMBOL", + "name": "_greater_than_equal" + }, + { + "type": "SYMBOL", + "name": "_shift_right" + }, + { + "type": "SYMBOL", + "name": "_shift_right_assign" + }, + { + "type": "SYMBOL", + "name": "_error_sentinel" + } + ], + "inline": [ + "global_decl" + ], + "supertypes": [], + "reserved": {} +} \ No newline at end of file