glsl-deparser
through stream that translates glsl-parser AST nodes into working glsl code
Last updated 10 years ago by chrisdickinson .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install glsl-deparser 
SYNC missed versions from official npm registry.

glsl-deparser


var Path = require('path')

var tokenizer = require('glsl-tokenizer')()
  , parser = require('glsl-parser')
  , deparser = require('glsl-deparser')

process.stdin
  .pipe(tokenizer)
  .pipe(parser())
  .pipe(deparser())             // <-- deparser!
  .pipe(process.stdout)

process.stdin.resume()

transform a stream of glsl-parser AST nodes into strings.

only operates on top-level statements emitted by glsl-parser, so the code it emits is executable by webgl.

api

deparser(whitespace_enabled=true, tab_text=' ')

Creates a readable/writable stream.

If no args are provided, whitespace is assumed to be enabled, and the tab text will be ' '.

If you pass false for the first arg, only syntactically significant whitespace will be emitted (it'll behave like a poor man's minifier).

If you pass true and tab text, that tab text will be used to indent code.

note

the big caveat is that preprocessor if statements (#if*, #endif) won't work unless each branch produces a parseable tree.

license

MIT

Current Tags

  • 1.0.0                                ...           latest (10 years ago)

5 Versions

  • 1.0.0                                ...           10 years ago
  • 0.0.3                                ...           11 years ago
  • 0.0.2                                ...           12 years ago
  • 0.0.1                                ...           12 years ago
  • 0.0.0                                ...           12 years ago
Maintainers (1)
Downloads
Total 4
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (0)
None

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