Releases: ShaderFrog/glsl-parser
5.0.0
PR that introduced this change
This introduces breaking changs to the utility API functions renameBindings
, renameFunctions
, and renameTypes
and changes their signatures to take the specific scope index, rather than the full scope.
This also changes the signature of the mangle()
function to no longer be passed the AST node in question to be mangled. @shaderfrog/core
used this as a hack to set a property directly on AST nodes (.doNotDescope
) to avoid other functions from touching it.
It also exports new individual utility functions renameBinding
etc, and a helper debug function.
These changes are largely in service of @shaderfrog/core
to support better AST manipulation by allowing for the renameFunctions to modify scope indices. This is to keep the scopes in sync with the manipulated AST, which allows for more utility functions to work on scope, and avoid re-visiting an AST to find variables after an AST manipulation.
2.1.1
npm install --save @shaderfrog/[email protected]
Fixes bug with \r
newlines in preprocessor. Thanks @06wj !
2.1.0
npm install --save @shaderfrog/[email protected]
- Updates readme with an errors section.
- Adds a
GlslSyntaxError
type alias for peggy errors, and exports it. - Adds tests for errors and an API function test
- Removes deprecated substr method
2.0.1
npm install --save @shaderfrog/[email protected]
Fixes a bug in the preprocessor that caused incorrect evaluation of #ifdef
macros if they appeared inside an #else
macro body.
Also fixed a bug where an empty macro (#define MACRO
) was expanding to null
rather than empty string.
You can see the macro syntax that triggered both of these bugs in the new unit tests added in this commit: 2c5d60a#diff-da981791d0e4f58af60303bcfe9662e76592a0c07cbd75271080a9f3669e4fa6
2.0.0
Introduced in this PR.
This is a significant set of changes, some breaking.
The main goal of this change is to support tracking whether or not functions and types have declarations in the scope. The type and function scope entries now have a definition
key, which points to the definition of a function or type.
Features:
- The parser now supports overloaded function tracking in scope. A function scope index went from
{ [fnName]: { references: AstNode[] }
to{ [fnName]: { [overloadSignature]: { declaration?: AstNode, references: AstNode[], ... } } }
. This is a breaking change. Note that if you're using therenameFunctions
utility function provided by the parser, this change may be opaque to you. - The semantic analysis of this library is still mostly non-existent, but there are now improved warnings for missing function and type definitions
- New
failOnWarn
parser option flag to raise errors on things like undefined variables.
Breaking API changes:
- Adds a new
TypeNameNode
AST node type, to distinguish a type name from an identifier in the AST. If you're using node visitors to visitidentifier
nodes, you'll need a new visitor fortype_name
nodes. - Removes
ParameterDeclaratorNode
and moves everything intoParameterDeclarationNode
- In the AST node Typescript definitions, any time I didn't know what node was, I put in
any
. I replaced that withAstNode
. I don't yet know if I want to keep this, becauseAstNode
could lead to more issues than it causes. It could lead to type errors and forced casting that wouldn't come along withany
. Like it might force you to make sure our node isn't aLiteralNode
even though technically the grammar doesn't allow for that. - Previously, a scope binding (aka a variable declaration use), had the type
{ initializer: declaration_ast_node, references: [ast_node, ...] }
, where theast_node
could be thedeclaration
node containing the identifier. It turns outinitializer
was never part of the Typescript type, so you might never have seen it. Either way,initializer
is renamed todeclaration
, and it now points to theidentifier
node rather than thedeclaration
.
Internal development:
- All of the functions that were defined in
src/parser/glsl-grammar.pegjs
are now rewritten in typescript and extracted into an external file. - Various clean-ups of the grammar, like removing the duplicate path
function_prototype_no_new_scope
- Cleanup of tsconfig.json file
- Adds the
tracer
Peggyjs option to the parser, for debugging - Removes preprocessor tests from parse.ast.ts
- Breaking out of source code into more logical files