package
r/w stream of glsl tokens
npm install glsl-tokenizerGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Maps GLSL string data into GLSL tokens, either synchronously or using a streaming API.
var tokenString = require('glsl-tokenizer/string')
var tokenStream = require('glsl-tokenizer/stream')
var fs = require('fs')
// Synchronously:
var tokens = tokenString(fs.readFileSync('some.glsl'))
// Streaming API:
fs.createReadStream('some.glsl')
.pipe(tokenStream())
.on('data', function(token) {
console.log(token.data, token.position, token.type)
})Returns an array of tokens given the GLSL source string src
You can specify opt.version string to use different keywords/builtins, such as '300 es' for WebGL2. Otherwise, will assume GLSL 100 (WebGL1).
var tokens = tokenizer(src, {
version: '300 es'
})Emits 'data' events whenever a token is parsed with a token object as output.
As above, you can specify opt.version.
{ 'type': TOKEN_TYPE
, 'data': "string of constituent data"
, 'position': integer position within the GLSL source
, 'line': line number within the GLSL source
, 'column': column number within the GLSL source }The available token types are:
block-comment: /* ... */line-comment: // ... \npreprocessor: # ... \noperator: Any operator. If it looks like punctuation, it's an operator.float: Optionally suffixed with fident: User defined identifier.builtin: Builtin function.eof: Emitted on end; data will === '(eof)'.integerwhitespacekeywordMIT, see LICENSE.md for further information.
mikolalysenko
mikolalysenko@gmail.com
yoshuawuyts
javascript@yosh.is
mikkoh
me@mikkoh.com
tatumcreative
tatum.creative@gmail.com
wwwtyro
wwwtyro@gmail.com
thibauts
thibaut.seguy@gmail.com
bpostlethwaite
post.ben.here@gmail.com
dfcreative
df.creative@gmail.com
erkaman
arnebackeric@gmail.com
gre
renaudeau.gaetan@gmail.com
rreusser
rsreusser@gmail.com
vorg
marcin.ignac@gmail.com
archmoj
arch.mojtaba.samimi@gmail.com
Estimated unpacked size across 8 packages.
564.8 kB
Includes dependencies.