57 lines
1.1 KiB
C
57 lines
1.1 KiB
C
|
#ifndef ASTNODE_H
|
||
|
#define ASTNODE_H
|
||
|
|
||
|
#include "token.h"
|
||
|
|
||
|
/**
|
||
|
* AST base class, all AST node classes extand this class. Class contains basic
|
||
|
* information about a nodes location in file.
|
||
|
*/
|
||
|
class AstNode {
|
||
|
public:
|
||
|
|
||
|
Span span;
|
||
|
|
||
|
AstNode() = default;
|
||
|
|
||
|
virtual ~AstNode(); // this is defined in Ast.cpp just so that the
|
||
|
// compiler doesn't complain about not knowing which
|
||
|
// object file to include the vtable in
|
||
|
AstNode(AstNode&&) = default;
|
||
|
|
||
|
AstNode& operator=(AstNode&&) = default;
|
||
|
AstNode(const AstNode&) = default;
|
||
|
|
||
|
AstNode& operator=(const AstNode&) = default;
|
||
|
|
||
|
};
|
||
|
|
||
|
class StringNode: public AstNode {
|
||
|
public:
|
||
|
std::string value;
|
||
|
};
|
||
|
|
||
|
|
||
|
class IdentifierNode: public AstNode {
|
||
|
public:
|
||
|
std::string value;
|
||
|
};
|
||
|
|
||
|
class NumberNode: public AstNode {
|
||
|
public:
|
||
|
long long int value;
|
||
|
NumberNode(std::string expression);
|
||
|
NumberNode(): value(0) {}
|
||
|
};
|
||
|
|
||
|
class CountNode: public AstNode {
|
||
|
public:
|
||
|
NumberNode first;
|
||
|
NumberNode second;
|
||
|
|
||
|
CountNode(NumberNode first, NumberNode second): first(first), second(second) {}
|
||
|
CountNode() {}
|
||
|
};
|
||
|
|
||
|
#endif // ASTNODE_H
|