glsl-token-scope
Infer the scope of each token in an array of GLSL tokens
Last updated 9 years ago by hughsk .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install glsl-token-scope 
SYNC missed versions from official npm registry.

glsl-token-scope

experimental

Infer the scope of each token in an array of GLSL tokens.

Usage

NPM

scope(tokens)

Where tokens is an array of tokens returned from glsl-tokenizer. Each token will be modified in-place, and given scope and stack properties.

token.scope is a unique number for the token's current scope.

token.stack is an array containing the scopes available to the current token.

Note that you must first determine the scope depth of each token using glsl-token-depth

var tokenize = require('glsl-tokenizer/string')
var depth    = require('glsl-token-depth')
var scope    = require('glsl-token-scope')
var fs       = require('fs')

var src = fs.readFileSync('shader.frag', 'utf8')
var tokens = tokenize(src)

depth(tokens)
scope(tokens)

tokens[0].scope // 0
tokens[1].scope // 0
tokens[2].scope // 1
tokens[3].scope // 1
tokens[4].scope // 0
tokens[5].scope // 2
// ...

tokens[0].stack // [0]
tokens[1].stack // [0]
tokens[2].stack // [0, 1]
tokens[3].stack // [0, 1]
tokens[4].stack // [0]
tokens[5].stack // [0, 2]
// ...

See Also

License

MIT. See LICENSE.md for details.

Current Tags

  • 1.1.2                                ...           latest (9 years ago)

5 Versions

  • 1.1.2                                ...           9 years ago
  • 1.1.1                                ...           10 years ago
  • 1.1.0                                ...           10 years ago
  • 1.0.1                                ...           10 years ago
  • 1.0.0                                ...           10 years ago
Downloads
Total 2
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (5)

© 2010 - cnpmjs.org x YWFE | Home | YWFE