Type check if and while conditions
This commit is contained in:
@ -1,6 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <boost/core/noncopyable.hpp>
|
||||
#include <memory>
|
||||
#include <elna/source/lexer.hpp>
|
||||
#include "elna/source/types.hpp"
|
||||
@ -482,7 +481,7 @@ namespace elna::source
|
||||
unary_operator operation() const noexcept;
|
||||
};
|
||||
|
||||
class parser : boost::noncopyable
|
||||
class parser
|
||||
{
|
||||
std::unique_ptr<expression> parse_unary_expression();
|
||||
std::unique_ptr<expression> parse_factor();
|
||||
@ -508,6 +507,7 @@ namespace elna::source
|
||||
|
||||
public:
|
||||
parser(lexer&& tokens);
|
||||
parser(const parser&) = delete;
|
||||
|
||||
/**
|
||||
* Parses a source text.
|
||||
|
@ -136,7 +136,8 @@ namespace elna::source
|
||||
dereference,
|
||||
argument,
|
||||
arithmetic,
|
||||
comparison
|
||||
comparison,
|
||||
condition
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -81,9 +81,12 @@ namespace elna::source
|
||||
void visit(procedure_definition *procedure) override;
|
||||
void visit(integer_literal *literal) override;
|
||||
void visit(boolean_literal *literal) override;
|
||||
void visit(variable_expression *expression) override;
|
||||
void visit(unary_expression *expression) override;
|
||||
void visit(binary_expression *expression) override;
|
||||
void visit(call_statement *statement) override;
|
||||
void visit(constant_definition *definition) override;
|
||||
void visit(while_statement *statement) override;
|
||||
void visit(if_statement *statement) override;
|
||||
};
|
||||
}
|
||||
|
@ -35,49 +35,54 @@ namespace elna::source
|
||||
};
|
||||
|
||||
/**
|
||||
* Constant information.
|
||||
* Information for a typed symbol.
|
||||
*/
|
||||
class constant_info final : public info
|
||||
class typed_info : public info
|
||||
{
|
||||
std::shared_ptr<const class type> m_type;
|
||||
|
||||
protected:
|
||||
typed_info(std::shared_ptr<const class type> type);
|
||||
|
||||
public:
|
||||
~typed_info() override;
|
||||
|
||||
std::shared_ptr<const class type> type() const noexcept;
|
||||
};
|
||||
|
||||
/**
|
||||
* Constant information.
|
||||
*/
|
||||
class constant_info final : public typed_info
|
||||
{
|
||||
std::int32_t m_value;
|
||||
|
||||
public:
|
||||
constant_info(std::shared_ptr<const class type> type, const std::int32_t value);
|
||||
~constant_info() override;
|
||||
|
||||
std::shared_ptr<const class type> type() const noexcept;
|
||||
std::int32_t value() const noexcept;
|
||||
};
|
||||
|
||||
/**
|
||||
* Variable information.
|
||||
*/
|
||||
class variable_info final : public info
|
||||
class variable_info final : public typed_info
|
||||
{
|
||||
std::shared_ptr<const class type> m_type;
|
||||
|
||||
public:
|
||||
std::ptrdiff_t offset{ 0 };
|
||||
|
||||
explicit variable_info(std::shared_ptr<const class type> type);
|
||||
~variable_info() override;
|
||||
std::shared_ptr<const class type> type() noexcept;
|
||||
};
|
||||
|
||||
/**
|
||||
* Procedure parameter information.
|
||||
*/
|
||||
class parameter_info final : public info
|
||||
class parameter_info final : public typed_info
|
||||
{
|
||||
std::shared_ptr<const class type> m_type;
|
||||
|
||||
public:
|
||||
std::ptrdiff_t offset{ 0 };
|
||||
|
||||
explicit parameter_info(std::shared_ptr<const class type> type);
|
||||
~parameter_info() override;
|
||||
std::shared_ptr<const class type> type() const noexcept;
|
||||
};
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user