Skip to main content

Crate tree_sitter_glsl_spec

Crate tree_sitter_glsl_spec 

Source
Expand description

This crate provides GLSL language support for the [tree-sitter] parsing library.

Typically, you will use the LANGUAGE constant to add this language to a tree-sitter Parser, and then use the parser to parse some code:

let code = r#"
    void fragment_shader() {
        gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
    }
"#;
let mut parser = tree_sitter::Parser::new();
let language = tree_sitter_glsl_spec::LANGUAGE;
parser
    .set_language(&language.into())
    .expect("Error loading GLSL parser");
let tree = parser.parse(code, None).unwrap();
assert!(!tree.root_node().has_error());

Constants§

CONSTRUCTOR_HEURISTICS_QUERY
Constructor heuristic query. Identifies function calls where the callee is a user-defined type name (capitalized identifier), which are likely struct constructors. Opt-in — not included in default highlighting.
HIGHLIGHTS_QUERY
Syntax highlighting query. Maps GLSL nodes to highlight capture names (@keyword, @function, @type, @operator, @variable, etc.). Includes built-in function/variable/constant recognition.
INJECTIONS_QUERY
Language injection query. Identifies #ifdef __cplusplus / #ifdef __STDC__ guard blocks and marks their foreign-language content for injection (cpp or c).
LANGUAGE
The tree-sitter LanguageFn for this grammar.
LOCALS_QUERY
Local variable tracking query. Defines scopes (functions, blocks, loops) and tracks identifier definitions and references within them.
NODE_TYPES
The content of the node-types.json file for this grammar.
TAGS_QUERY
Tags query for code navigation. Captures function definitions, type definitions, variable declarations, function calls, and type references.
VERSION_TAGS_QUERY
Version tags query. Captures GLSL constructs whose availability depends on a minimum #version (e.g., uint requires 130, double requires 400). Intended for post-parse validation, not syntax highlighting.