Skip to content

AST visitors - #254

Merged
WerWolv merged 4 commits into
WerWolv:masterfrom
Nemoumbra:visitors
Sep 10, 2026
Merged

WerWolv merged 4 commits into
WerWolv:masterfrom
Nemoumbra:visitors

Conversation

@Nemoumbra

Copy link
Copy Markdown
Contributor

This adds the a visitor framework for traversing the AST.
It consists of an abstract class (iface) ASTVisitor which implements visit for all the available AST node types.... +- the actual ASTNode... maybe we don't need this fallback... idk......... Also a pure virtual method accept(ASTVisitor&) for AST nodes. The visitor pattern, nothing fancy.
I also added getters for nodes which didn't expose some valuable fields.

One visitor example is the iface for writing AST validators, called ASTValidator. It implements all methods as empty, so you don't need to do that for all the children when you don't care about some nodes.
The AST validators are combined in a pipeline, which is meant to replace the current validator.

This branch is created from the previous one, so it has the commits from the last PR. I just couldn't wait to share this code.
I don't want to commit more until we sort out the includes, namespaces or filesystem locations for my additions. Then I'll follow with the 2 validators and also a CLI command to generate GV files (this is an example for non-validating visitor).

Comment thread lib/include/pl/core/ast/visitors/ast_validator.hpp Outdated
Comment thread lib/include/pl/core/ast/visitors/ast_validator.hpp Outdated
Comment thread lib/include/pl/core/validator.hpp Outdated
Comment thread lib/include/pl/pattern_language.hpp
Comment thread lib/source/pl/pattern_language.cpp Outdated
Comment thread lib/source/pl/pattern_language.cpp Outdated
@WerWolv
WerWolv merged commit 0173efc into WerWolv:master Sep 10, 2026
5 checks passed
@Nemoumbra
Nemoumbra deleted the visitors branch September 10, 2026 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants