Skip to content
This repository was archived by the owner on Oct 12, 2026. It is now read-only.

Commit c524759

Browse files
committed
Add more expression AstNode.
1 parent 633b0c8 commit c524759

8 files changed

Lines changed: 69 additions & 4 deletions

File tree

‎include/lbd/frontend/ast/expression/IdentifierExpression.hpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace lbd::frontend::ast::expression
77
class IdentifierExpression final : Expression
88
{
99
public:
10-
IdentifierExpression(const source::Range& range, std::string name);
10+
IdentifierExpression(const source::Range& range, std::string name) noexcept;
1111

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#pragma once
2+
3+
#include <lbd/frontend/ast/expression/Expression.hpp>
4+
#include <lbd/frontend/ast/expression/IdentifierExpression.hpp>
5+
6+
namespace lbd::frontend::ast::expression
7+
{
8+
class NumberExpression final : Expression
9+
{
10+
public:
11+
NumberExpression(const source::Range& range, std::string value) noexcept;
12+
13+
void print(std::ostream& outputStream, size_t indent) const noexcept override;
14+
15+
private:
16+
IdentifierExpression argumentIdentifierExpression;
17+
interpreter::type::Type argumentType;
18+
std::unique_ptr<Expression> expression;
19+
source::Location location;
20+
};
21+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#pragma once
2+
3+
#include <lbd/frontend/ast/expression/Expression.hpp>
4+
5+
namespace lbd::frontend::ast::expression
6+
{
7+
class NumberExpression final : Expression
8+
{
9+
public:
10+
NumberExpression(const source::Range& range, double value) noexcept;
11+
12+
void print(std::ostream& outputStream, size_t indent) const noexcept override;
13+
14+
private:
15+
double value;
16+
};
17+
}

‎include/lbd/frontend/ast/expression/StringExpression.hpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace lbd::frontend::ast::expression
77
class StringExpression final : Expression
88
{
99
public:
10-
StringExpression(const source::Range& range, std::string value);
10+
StringExpression(const source::Range& range, std::string value) noexcept;
1111

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

‎include/lbd/type/TypeKind.hpp‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#pragma once
2+
3+
namespace lbd::type
4+
{
5+
enum class TypeKind
6+
{
7+
NAMED, // Number, String
8+
VARIABLE, // a, b
9+
APPLIED, // List<Number>, Map<String, Number>
10+
FUNCTION, // String -> Number
11+
QUALIFIED, // Eq a => a -> a
12+
ANY,
13+
};
14+
}

‎src/frontend/ast/expression/IdentifierExpression.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace lbd::frontend::ast::expression
44
{
5-
IdentifierExpression::IdentifierExpression(const source::Range& range, std::string name)
5+
IdentifierExpression::IdentifierExpression(const source::Range& range, std::string name) noexcept
66
: Expression(AstNodeKind::IDENTIFIER_EXPRESSION, range), name(std::move(name)) {}
77

88
void IdentifierExpression::print(std::ostream& outputStream, const size_t indent) const noexcept
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include <lbd/frontend/ast/expression/NumberExpression.hpp>
2+
3+
namespace lbd::frontend::ast::expression
4+
{
5+
NumberExpression::NumberExpression(const source::Range& range, const double value) noexcept
6+
: Expression(AstNodeKind::NUMBER_EXPRESSION, range), value(value) {}
7+
8+
void NumberExpression::print(std::ostream& outputStream, const size_t indent) const noexcept
9+
{
10+
printIndent(outputStream, indent);
11+
outputStream << value;
12+
}
13+
}

‎src/frontend/ast/expression/StringExpression.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace lbd::frontend::ast::expression
44
{
5-
StringExpression::StringExpression(const source::Range& range, std::string value)
5+
StringExpression::StringExpression(const source::Range& range, std::string value) noexcept
66
: Expression(AstNodeKind::STRING_EXPRESSION, range), value(std::move(value)) {}
77

88
void StringExpression::print(std::ostream& outputStream, const size_t indent) const noexcept

0 commit comments

Comments
 (0)