Package Exports
- glsl-token-depth
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (glsl-token-depth) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
glsl-token-depth
Determine the scope depth of an array of GLSL tokens.
Useful for inferring the scope of variables in a GLSL shader without having to fully parse the source.
Usage
depth(tokens)
Where tokens
is an array of tokens returned from
glsl-tokenizer
. Each token will
be modified in-place, and given a depth
property.
var tokenize = require('glsl-tokenizer/string')
var depth = require('glsl-token-depth')
var fs = require('fs')
var src = fs.readFileSync('shader.frag', 'utf8')
var tokens = tokenize(src)
depth(tokens)
tokens[0].depth // 0
tokens[1].depth // 0
tokens[2].depth // 0
tokens[3].depth // 0
tokens[4].depth // 1
// ...
See Also
License
MIT. See LICENSE.md for details.