# glsl-token-scope

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

Latest version **1.1.2** (published 2015-12-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install glsl-token-scope
pnpm add glsl-token-scope
yarn add glsl-token-scope
bun add glsl-token-scope
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.2 |
| Published | 2015-12-07 |
| First published | 2014-12-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Hugh Kennedy |
| Maintainers | hughsk, mattdesl, mikolalysenko, chrisdickinson, substack, thibauts, yoshuawuyts |
| Keywords | ecosystem:stackgl, glsl, tokens, syntax |

## Links

- npm: https://www.npmjs.com/package/glsl-token-scope
- Repository: https://github.com/stackgl/glsl-token-scope
- Issues: https://github.com/stackgl/glsl-token-scope/issues
- npm.io page: https://npm.io/package/glsl-token-scope

## Alternatives

- [@oh-my-pi/pi-natives](https://npm.io/package/@oh-my-pi/pi-natives.md) — 51.8K weekly downloads
- [@capgo/capacitor-light-sensor](https://npm.io/package/@capgo/capacitor-light-sensor.md) — 3.0K weekly downloads
- [@heyhuynhgiabuu/pi-diff](https://npm.io/package/@heyhuynhgiabuu/pi-diff.md) — 492 weekly downloads
- [@lotsa/verdant-lang-asm](https://npm.io/package/@lotsa/verdant-lang-asm.md) — 38 weekly downloads
- [new-era-syntax](https://npm.io/package/new-era-syntax.md) — 20 weekly downloads

## Recent versions

- 1.1.2 (latest) — 2015-12-07
- 1.1.1 — 2015-03-06
- 1.1.0 — 2015-01-04
- 1.0.1 — 2014-12-14
- 1.0.0 — 2014-12-14

## README

# glsl-token-scope

[![experimental](http://badges.github.io/stability-badges/dist/experimental.svg)](http://github.com/badges/stability-badges)

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

## Usage

[![NPM](https://nodei.co/npm/glsl-token-scope.png)](https://nodei.co/npm/glsl-token-scope/)

### `scope(tokens)`

Where `tokens` is an array of tokens returned from
[`glsl-tokenizer`](http://github.com/stackgl/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`](http://github.com/stackgl/glsl-token-depth)

``` javascript
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

* [stackgl/glsl-tokenizer](http://github.com/stackgl/glsl-tokenizer)
* [stackgl/glsl-token-depth](http://github.com/stackgl/glsl-token-depth)

## License

MIT. See [LICENSE.md](http://github.com/stackgl/glsl-token-scope/blob/master/LICENSE.md) for details.

---
_Source: https://npm.io/package/glsl-token-scope · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
