82 lines
1.6 KiB
C++
82 lines
1.6 KiB
C++
#pragma once
|
|
#include "ast.hpp"
|
|
#include "lexer.hpp"
|
|
#include <inttypes.h>
|
|
#include <float.h>
|
|
#include <math.h>
|
|
#include <memory>
|
|
#include <string>
|
|
|
|
namespace blitz {
|
|
namespace AST {
|
|
enum class ValueType : int8_t {
|
|
Unknown,
|
|
Number,
|
|
Decimal,
|
|
String,
|
|
Type,
|
|
};
|
|
|
|
class ValueExpression : public Expression {
|
|
public:
|
|
virtual ValueType GetType() = 0;
|
|
};
|
|
|
|
class ConstExpression : public ValueExpression {
|
|
public:
|
|
ConstExpression(std::string& name, std::unique_ptr<ValueExpression> value);
|
|
virtual ~ConstExpression();
|
|
|
|
virtual ValueType GetType() override;
|
|
|
|
private:
|
|
std::string m_name;
|
|
std::unique_ptr<ValueExpression> m_value;
|
|
};
|
|
|
|
class VariableExpression : public ValueExpression {
|
|
public:
|
|
VariableExpression(std::string& name, ValueType type = ValueType::Number);
|
|
virtual ~VariableExpression();
|
|
|
|
virtual ValueType GetType() override;
|
|
|
|
private:
|
|
std::string m_name;
|
|
ValueType m_type;
|
|
};
|
|
|
|
class NumberExpression : public ValueExpression {
|
|
public:
|
|
NumberExpression(int32_t value);
|
|
virtual ~NumberExpression();
|
|
|
|
virtual ValueType GetType() override;
|
|
|
|
private:
|
|
int32_t value;
|
|
};
|
|
|
|
class DecimalExpression : public ValueExpression {
|
|
public:
|
|
DecimalExpression(float_t value);
|
|
virtual ~DecimalExpression();
|
|
|
|
virtual ValueType GetType() override;
|
|
|
|
private:
|
|
float_t value;
|
|
};
|
|
|
|
class StringExpression : public ValueExpression {
|
|
public:
|
|
StringExpression(std::string value);
|
|
virtual ~StringExpression();
|
|
|
|
virtual ValueType GetType() override;
|
|
|
|
private:
|
|
std::string value;
|
|
};
|
|
}
|
|
} |