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 therenameFunctionsutility 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
failOnWarnparser option flag to raise errors on things like undefined variables.
Breaking API changes:
- Adds a new
TypeNameNodeAST node type, to distinguish a type name from an identifier in the AST. If you're using node visitors to visitidentifiernodes, you'll need a new visitor fortype_namenodes. - Removes
ParameterDeclaratorNodeand 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, becauseAstNodecould 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 aLiteralNodeeven 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_nodecould be thedeclarationnode containing the identifier. It turns outinitializerwas never part of the Typescript type, so you might never have seen it. Either way,initializeris renamed todeclaration, and it now points to theidentifiernode rather than thedeclaration.
Internal development:
- All of the functions that were defined in
src/parser/glsl-grammar.pegjsare 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
tracerPeggyjs option to the parser, for debugging - Removes preprocessor tests from parse.ast.ts
- Breaking out of source code into more logical files