Refactor to support tracking undeclared functions and types #11
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
{ [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.failOnWarn
parser option flag to raise errors on things like undefined variables.Breaking API changes:
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.ParameterDeclaratorNode
and moves everything intoParameterDeclarationNode
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.{ 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:
src/parser/glsl-grammar.pegjs
are now rewritten in typescript and extracted into an external file.function_prototype_no_new_scope
tracer
Peggyjs option to the parser, for debugging