diff --git a/lang-quote/src/tokenize.rs b/lang-quote/src/tokenize.rs index 812b5478b..a826443b9 100644 --- a/lang-quote/src/tokenize.rs +++ b/lang-quote/src/tokenize.rs @@ -1117,6 +1117,11 @@ fn tokenize_declaration(d: &ast::Declaration) -> TokenStream { let ident = tokenize_identifier(ident); quote! { glsl_lang::ast::DeclarationData::Invariant(#ident) } } + + ast::DeclarationData::TypeOnly(ref q) => { + let q = tokenize_type_qualifier(q); + quote! { glsl_lang::ast::DeclarationData::TypeOnly(#q) } + } }; let span = tokenize_span(&d.span); diff --git a/lang-quote/tests/lib.rs b/lang-quote/tests/lib.rs index 83b9d64e1..9133cbd47 100644 --- a/lang-quote/tests/lib.rs +++ b/lang-quote/tests/lib.rs @@ -125,3 +125,10 @@ fn statement_var_decl() { } }; } + +#[test] +fn typeonly_multiview_qualifier() { + let _ = glsl! { + layout (num_views = 2) in; + }; +} diff --git a/lang-types/src/ast.rs b/lang-types/src/ast.rs index 22032b0d1..8ba8e8186 100644 --- a/lang-types/src/ast.rs +++ b/lang-types/src/ast.rs @@ -991,6 +991,8 @@ pub enum DeclarationData { Block(Block), /// Invariant declaration Invariant(Identifier), + /// Type-only declaration + TypeOnly(TypeQualifier), } impl_node_content! { diff --git a/lang/src/parser.lalrpop b/lang/src/parser.lalrpop index eeaaf2517..5678349b6 100644 --- a/lang/src/parser.lalrpop +++ b/lang/src/parser.lalrpop @@ -694,6 +694,7 @@ declaration: ast::Declaration = { ";" => p.spanned(l, r), ";" => ast::DeclarationData::Block(b).spanned(l, r), "invariant" ";" => ast::DeclarationData::Invariant(i).spanned(l, r), + ";" => ast::DeclarationData::TypeOnly(q).spanned(l, r), }; function_definition: ast::FunctionDefinition = { diff --git a/lang/src/transpiler/glsl.rs b/lang/src/transpiler/glsl.rs index 2907083d6..b3c162677 100644 --- a/lang/src/transpiler/glsl.rs +++ b/lang/src/transpiler/glsl.rs @@ -1539,6 +1539,9 @@ where f.write_char(' ')?; show_identifier(f, ident, state)?; } + ast::DeclarationData::TypeOnly(ref q) => { + show_type_qualifier(f, q, state)?; + } } state.write_declaration_terminator(f) diff --git a/lang/src/visitor.rs b/lang/src/visitor.rs index 0617b9f72..23d94a44f 100644 --- a/lang/src/visitor.rs +++ b/lang/src/visitor.rs @@ -740,6 +740,8 @@ macro_rules! make_host_trait { ast::DeclarationData::Block(block) => block.$mthd_name(visitor), ast::DeclarationData::Invariant(ident) => ident.$mthd_name(visitor), + + ast::DeclarationData::TypeOnly(q) => q.$mthd_name(visitor), } } }