1.1.14 • Published 8 years ago
glsl-man v1.1.14
GLSL manipulator
GLSL parser and code generator based on Google's glsl-unit grammar.
Install
npm install glsl-manUsage
Parsing
var glsl = require('glsl-man');
var ast = glsl.parse(source);Deparsing
var glsl = require('glsl-man');
var ast = glsl.parse(source);
var generated = glsl.string(ast);Querying
var glsl = require('glsl-man');
var ast = glsl.parse(source);
var uniforms = glsl.query.all(
ast,
glsl.query.selector('declarator[typeAttribute] > type[qualifier=uniform]'));API
Parsing
glsl.parse(string)- Generates AST from GLSL- string - GLSL source code
Deparsing
glsl.string(ASTNode, options)- Generates GLSL from AST- ASTNode - Any node from the tree returned by
parse(string) - options - The default options are described below:
- ASTNode - Any node from the tree returned by
{
tab: '\t', // Character used for tab
space: ' ', // Character used for space
newline: '\n', // Character used for newlines
// The following should not be altered to produce valid GLSL
terminator: ';', // Character used to terminate a statement
comma: ',' // Character used for comma
}glsl.wrap(ASTNode)- Wraps the given node in a 'root' scope. Useful for generating valid code from arbitrary AST subnodes.- ASTNode - Any node from the tree returned by
parse(string)
- ASTNode - Any node from the tree returned by
Querying
glsl.query.selector(string)- Returns a selector- string - cssauron selector
glsl.query.all(node, selector, matches)- Searches the tree depth first and returns all nodes that match the selector- node - AST node
- selector - The selector to test against
- matches - Array to store matched nodes (optional)
glsl.query.first(node, selector)- Searches the tree depth first and returns the first node that matches the selector- node - AST node
- selector - The selector to test against
glsl.query.children(node, selector, matches)- Searches only the immediate subnodes of the given node and returns all children that match the selector- node - AST node
- selector - The selector to test against
- matches - Array to store matched nodes (optional)
glsl.query.firstChild(node, selector)- Searches only the immediate subnodes of the given node and returns the first node that matches the selector- node - AST node
- selector - The selector to test against
glsl.query.subnodes(node)- Returns a list of all subnodes of the given node that can be further traversed- node - AST node
Modifying
glsl.mod.find(node)- Returns an object withindexandstatementskeys.- node - AST node
glsl.mod.remove(node)- Removes the given node from it's AST.- node - AST node
glsl.mod.replace(node, newNode)- Replaces the given node withnewNode.- node - AST node
- newNode - AST node or Array of AST nodes
glsl.mod.add(node, newNode, after)- InsertsnewNodebefore or afternode.- node - AST node
- newNode - AST node or Array of AST nodes
- after - (optional) Boolean
glsl.mod.addBefore(node, newNode)- Shortcut toglsl.mod.add.
glsl.mod.addAfter(node, newNode)- Shortcut toglsl.mod.add.
1.1.14
8 years ago
1.1.13
8 years ago
1.1.12
9 years ago
1.1.11
9 years ago
1.1.10
9 years ago
1.1.9
9 years ago
1.1.8
9 years ago
1.1.7
9 years ago
1.1.6
9 years ago
1.1.5
9 years ago
1.1.4
9 years ago
1.1.3
9 years ago
1.1.2
10 years ago
1.1.1
10 years ago
1.1.0
10 years ago
1.0.9
10 years ago
1.0.8
10 years ago
1.0.7
10 years ago
1.0.6
10 years ago
1.0.5
10 years ago
1.0.4
10 years ago
1.0.3
10 years ago
1.0.2
10 years ago
1.0.1
10 years ago
1.0.0
10 years ago
