erick-alcachofa 552cda58e7
feat(Parser): Introduce AST toString and basic parser structure
Signed-off-by: erick-alcachofa <erick@artichoke.dev>

This commit introduces the foundational structure for the parser and
Abstract Syntax Tree (AST). It includes a new `Parser.hpp` header that
outlines the primary parsing functions for top-level declarations like
`modules`, `structs`, `enums`, and `functions`. It also adds a
`toString` function for the AST to aid in debugging and visualization.

The commit also updates the `Expected.hpp` utility by adding new error
codes like `ecUnexpectedToken`, `ecExpectedSemicolon`,
`ecImportInsideModule`, and `ecUnimplemented` to provide more granular
and descriptive parsing errors. The `Tokenizer` has been updated to use
these new, more specific exceptions.
2025-10-15 16:12:19 -06:00

34 lines
746 B
C++

#pragma once
#include <artichoke/Parser/AST/Common.hpp>
#include <artichoke/Parser/AST/Declarations.hpp>
namespace arti::lang::ast {
namespace nodes {
/* Forward declaration of types */
/* Main declaration node types */
struct CompilationUnit;
} // namespace nodes
/* Public Aliases */
using CompilationUnitNode = Ptr<nodes::CompilationUnit>;
using AST = CompilationUnitNode;
/* Node definitions */
struct nodes::CompilationUnit {
String unitName;
Vector<TopLevelDeclNode> declarations;
};
template <ASTNodePtr Node>
auto MakeNode() {
return std::make_unique<typename Node::element_type>();
}
std::string toString(const AST &tree, std::size_t padding = 0);
} // namespace arti::lang::ast