4 Commits

Author SHA1 Message Date
b99f3586dc
chore(license): Added NOTICE header to all source files
Signed-off-by: erick-alcachofa <erick@artichoke.dev>
2025-12-25 13:12:41 -06:00
0a3971f18e
refactor(ast): refactor AST printing to support DOT graph and improved string output
Signed-off-by: erick-alcachofa <erick@artichoke.dev>

This commit refactors the AST printing functionality by moving the
human-readable `toString` implementation into its own file
(`lib/src/Parser/AST/toString.cpp`) and introducing a new `toDot`
function in `lib/src/Parser/AST/toDot.cpp` for generating Graphviz DOT
format output.

The `AST.hpp` header is updated to declare both the new `toDot` function
and the modified `toString` function, which now uses an optional
`prefix` parameter for prettier tree output. The `Token.hpp`/`Token.cpp`
files are also adjusted to have `toString(const TokenV &)` return a
`std::string_view`, and `toString(const Token &)` provides a cleaner
string representation using only the token's value.
2025-10-19 21:54:24 -06:00
5e94021ae5
feat(AST): Add node factory helper and missing identifier node
Signed-off-by: erick-alcachofa <erick@artichoke.dev>

This commit introduces an utility factory function and structural
improvements to the Abstract Syntax Tree (AST).

* Adds a new `ASTNodePtr` C++20 concept to constrain template types to
  be `std::unique_ptr`s pointing to AST nodes.
* Introduces a `MakeNode<T>()` factory function that uses this concept
  to simplify and standardize the creation of new nodes.
* Fixed `NamespacedType` and added the missing `NamespacedIdentifier`
  node.
2025-10-12 18:55:34 -06:00
c4c3d71cc4
feat(AST): Refactor AST nodes into a multi-file structure
Signed-off-by: erick-alcachofa <erick@artichoke.dev>

This commit refactors the AST (Abstract Syntax Tree) to improve code
organization, clarity, and maintainability. The large single-file AST
definition has been split into multiple, logically grouped header files.

The key changes are:

- **New File Structure**: The single `Node.hpp` file is replaced by a
  modular structure consisting of `Common.hpp`, `Declarations.hpp`,
  `Expressions.hpp`, `Literals.hpp`, `Statements.hpp`, and a new central
  `AST.hpp` header.
- **Improved Naming**: All AST node structs and their aliases have been
  renamed to follow a consistent `[NodeName][NodeType]` convention, such
  as `StructDeclaration` and `StructDeclNode`.
- **Namespace Change**: The `node` namespace has been replaced by
  `arti::lang::ast::nodes` to provide better encapsulation and prevent
  naming conflicts.
- **Type Aliases**: Helper aliases like `String`, `Vector`, and
  `Variant` have been introduced to simplify the code.
2025-10-12 17:40:29 -06:00