Skip to content
This repository was archived by the owner on Oct 12, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 18 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ include(FetchContent)

FetchContent_Declare(
fmt
GIT_REPOSITORY https://github.com/fmtlib/fmt.git
GIT_REPOSITORY https://github.com/lambda-discipline/fmtlib-fmt.git
GIT_TAG 11.2.0
)

FetchContent_Declare(
replxx
GIT_REPOSITORY https://github.com/AmokHuginnsson/replxx.git
GIT_TAG master
GIT_REPOSITORY https://github.com/lambda-discipline/amokhuginnsson-replxx.git
GIT_TAG release-0.0.4
)

FetchContent_Declare(
CLI11
GIT_REPOSITORY https://github.com/CLIUtils/CLI11.git
GIT_REPOSITORY https://github.com/lambda-discipline/cliutils-cli11.git
GIT_TAG v2.5.0
)

Expand Down Expand Up @@ -87,20 +87,24 @@ target_link_libraries(lbdDiagnostics PUBLIC
fmt::fmt
)

###### TYPE ######
###### TYPES (Unified Type System) ######

file(GLOB_RECURSE TYPE_SOURCE_FILES CONFIGURE_DEPENDS
${PROJECT_SOURCE_DIR}/src/type/*.cpp
file(GLOB_RECURSE TYPES_SOURCE_FILES CONFIGURE_DEPENDS
${PROJECT_SOURCE_DIR}/src/types/*.cpp
)

add_library(lbdType STATIC
${TYPE_SOURCE_FILES}
add_library(lbdTypes STATIC
${TYPES_SOURCE_FILES}
)

target_include_directories(lbdType PUBLIC
target_include_directories(lbdTypes PUBLIC
${PROJECT_SOURCE_DIR}/include
)

target_link_libraries(lbdTypes PUBLIC
lbdDiagnostics
)

###### FRONTEND ######

file(GLOB_RECURSE FRONTEND_SOURCE_FILES CONFIGURE_DEPENDS
Expand All @@ -117,6 +121,7 @@ target_include_directories(lbdFrontend PUBLIC

target_link_libraries(lbdFrontend PUBLIC
lbdDiagnostics
lbdTypes
)

###### RUNTIME ######
Expand All @@ -135,6 +140,7 @@ target_include_directories(lbdRuntime PUBLIC

target_link_libraries(lbdRuntime PUBLIC
lbdDiagnostics
lbdTypes
)

###### MAIN EXECUTABLE ######
Expand All @@ -158,7 +164,7 @@ target_link_libraries(lbd PRIVATE
lbdDiagnostics
lbdFrontend
lbdRuntime
lbdType
lbdTypes
replxx
CLI11::CLI11
)
Expand All @@ -174,6 +180,7 @@ endif ()

enable_warnings(lbdSource)
enable_warnings(lbdDiagnostics)
enable_warnings(lbdTypes)
enable_warnings(lbdFrontend)
enable_warnings(lbdRuntime)
enable_warnings(lbd)
Expand Down
6 changes: 3 additions & 3 deletions include/lbd/frontend/ast/expression/LambdaExpression.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

#include <lbd/frontend/ast/expression/Expression.hpp>
#include <lbd/frontend/ast/expression/IdentifierExpression.hpp>
#include <lbd/type/Type.hpp>
#include <lbd/types/Core.hpp>

namespace lbd::frontend::ast::expression
{
class LambdaExpression final : public Expression
{
public:
LambdaExpression(const source::Range &range, IdentifierExpressionPtr argumentIdentifierExpressionPtr,
type::TypePtr argumentTypePtr, ExpressionPtr expressionPtr) noexcept;
types::TypePtr argumentTypePtr, ExpressionPtr expressionPtr) noexcept;

void print(std::ostream &outputStream, size_t indent) const noexcept override;

Expand All @@ -20,7 +20,7 @@ namespace lbd::frontend::ast::expression

private:
IdentifierExpressionPtr argumentIdentifierExpressionPtr;
type::TypePtr argumentTypePtr;
types::TypePtr argumentTypePtr;
ExpressionPtr expressionPtr;
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <lbd/frontend/ast/expression/Expression.hpp>
#include <lbd/frontend/ast/expression/IdentifierExpression.hpp>
#include <lbd/frontend/ast/statement/Statement.hpp>
#include <lbd/type/Type.hpp>
#include <lbd/types/Core.hpp>

namespace lbd::frontend::ast::statement
{
Expand All @@ -12,7 +12,7 @@ namespace lbd::frontend::ast::statement
public:
SymbolDefinitionStatement(const source::Range &range,
expression::IdentifierExpressionPtr symbolNameIdentifierExpressionPtr,
type::TypePtr symbolTypePtr, expression::ExpressionPtr expressionPtr) noexcept;
types::TypePtr symbolTypePtr, expression::ExpressionPtr expressionPtr) noexcept;

void print(std::ostream &outputStream, size_t indent) const noexcept override;

Expand All @@ -24,7 +24,7 @@ namespace lbd::frontend::ast::statement

private:
expression::IdentifierExpressionPtr symbolNameIdentifierExpressionPtr;
type::TypePtr symbolTypePtr;
types::TypePtr symbolTypePtr;
expression::ExpressionPtr expressionPtr;
};
}
12 changes: 6 additions & 6 deletions include/lbd/frontend/parser/Parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <lbd/frontend/ast/expression/IdentifierExpression.hpp>
#include <lbd/frontend/ast/statement/Statement.hpp>
#include <lbd/frontend/lexer/Lexer.hpp>
#include <lbd/type/Type.hpp>
#include <lbd/types/Core.hpp>

namespace lbd::frontend::parser
{
Expand Down Expand Up @@ -40,16 +40,16 @@ namespace lbd::frontend::parser

[[nodiscard]] ast::expression::ExpressionPtr parseNumberExpression() const;

[[nodiscard]] type::TypePtr parseType() const;
[[nodiscard]] types::TypePtr parseType() const;

/// Tries to parse a qualified type, if failed fallbacks to parsing function type.
[[nodiscard]] type::TypePtr parseQualifiedType() const;
[[nodiscard]] types::TypePtr parseQualifiedType() const;

[[nodiscard]] type::TypePtr parseFunctionType() const;
[[nodiscard]] types::TypePtr parseFunctionType() const;

[[nodiscard]] type::TypePtr parseAppliedType() const;
[[nodiscard]] types::TypePtr parseAppliedType() const;

[[nodiscard]] type::TypePtr parsePrimaryType() const;
[[nodiscard]] types::TypePtr parsePrimaryType() const;

Context &context;
lexer::Lexer &lexer;
Expand Down
12 changes: 6 additions & 6 deletions include/lbd/runtime/Builtins.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@

#include <lbd/Context.hpp>
#include <lbd/runtime/Interpreter.hpp>
#include <lbd/runtime/Type.hpp>
#include <lbd/types/Core.hpp>

namespace lbd::runtime::builtins
{
// Helper functions to make defining native-functions easier.
using TypePointer = std::shared_ptr<type::Type>;
using TypePointer = types::TypePtr;

TypePointer simpleType(type::TypeTag tag, bool hardCheck = true);
TypePointer simpleType(types::TypeTag tag, bool hardCheck = true);

TypePointer listType();

std::shared_ptr<type::FunctionType> functionType(const std::vector<TypePointer> &argumentTypes,
const TypePointer &returnType, bool isVariadic = false);
TypePointer functionType(const std::vector<TypePointer> &argumentTypes,
const TypePointer &returnType, bool isVariadic = false);

/// Type-Checking of native-function's signature must be handled by the user.
std::vector<NativeFunction> getBuiltins(Context & context);
std::vector<NativeFunction> getBuiltins(Context &context);
}
12 changes: 4 additions & 8 deletions include/lbd/runtime/Interpreter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@
#include <lbd/frontend/Program.hpp>
#include <lbd/frontend/ast/AstNode.hpp>
#include <lbd/frontend/ast/expression/Expression.hpp>

namespace lbd::runtime::type
{
struct FunctionType;
}
#include <lbd/types/Core.hpp>

namespace lbd::runtime
{
Expand Down Expand Up @@ -73,11 +69,11 @@ namespace lbd::runtime
using Implementation = std::function<std::pair<Value, ResultOptions>
(const std::vector<std::shared_ptr<Thunk>> &, const std::shared_ptr<Environment> &)>;

NativeFunction(std::string name, std::shared_ptr<type::FunctionType> signature, Implementation implementation);
NativeFunction(std::string name, types::TypePtr signature, Implementation implementation);

[[nodiscard]] std::string getName() const;

[[nodiscard]] std::shared_ptr<type::FunctionType> getSignature() const;
[[nodiscard]] types::TypePtr getSignature() const;

[[nodiscard]] Implementation getImplementation() const;

Expand All @@ -89,7 +85,7 @@ namespace lbd::runtime

private:
std::string name;
std::shared_ptr<type::FunctionType> signature;
types::TypePtr signature;
Implementation implementation;
};

Expand Down
117 changes: 0 additions & 117 deletions include/lbd/runtime/Type.hpp

This file was deleted.

Loading
Loading