152 lines
3.2 KiB
C
152 lines
3.2 KiB
C
|
#ifndef __ANTHEM__AST_H
|
||
|
#define __ANTHEM__AST_H
|
||
|
|
||
|
#include <anthem/ASTForward.h>
|
||
|
|
||
|
namespace anthem
|
||
|
{
|
||
|
namespace ast
|
||
|
{
|
||
|
|
||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
//
|
||
|
// AST
|
||
|
//
|
||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
|
||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
// Primitives
|
||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
|
||
|
struct BinaryOperation
|
||
|
{
|
||
|
enum class Operator
|
||
|
{
|
||
|
Add,
|
||
|
Subtract
|
||
|
};
|
||
|
|
||
|
Operator operator_;
|
||
|
Term left;
|
||
|
Term right;
|
||
|
};
|
||
|
|
||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
|
||
|
struct Boolean
|
||
|
{
|
||
|
bool value = false;
|
||
|
};
|
||
|
|
||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
|
||
|
struct Equals
|
||
|
{
|
||
|
Term left;
|
||
|
Term right;
|
||
|
};
|
||
|
|
||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
|
||
|
struct Function
|
||
|
{
|
||
|
const char *name = nullptr;
|
||
|
std::vector<Term> arguments;
|
||
|
};
|
||
|
|
||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
|
||
|
struct Integer
|
||
|
{
|
||
|
int value;
|
||
|
};
|
||
|
|
||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
|
||
|
struct IntegerRange
|
||
|
{
|
||
|
Integer from;
|
||
|
Integer to;
|
||
|
};
|
||
|
|
||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
|
||
|
struct Predicate
|
||
|
{
|
||
|
const char *name = nullptr;
|
||
|
std::vector<Term> arguments;
|
||
|
};
|
||
|
|
||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
|
||
|
struct Variable
|
||
|
{
|
||
|
const char *name = nullptr;
|
||
|
};
|
||
|
|
||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
// Expressions
|
||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
|
||
|
struct And
|
||
|
{
|
||
|
std::vector<Formula> arguments;
|
||
|
};
|
||
|
|
||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
|
||
|
struct Biconditional
|
||
|
{
|
||
|
Formula left;
|
||
|
Formula right;
|
||
|
};
|
||
|
|
||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
|
||
|
struct Exists
|
||
|
{
|
||
|
std::vector<VariablePointer> variables;
|
||
|
Formula formula;
|
||
|
};
|
||
|
|
||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
|
||
|
struct ForAll
|
||
|
{
|
||
|
std::vector<VariablePointer> variables;
|
||
|
Formula formula;
|
||
|
};
|
||
|
|
||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
|
||
|
struct Implies
|
||
|
{
|
||
|
Formula antecedent;
|
||
|
Formula consequent;
|
||
|
};
|
||
|
|
||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
|
||
|
struct Not
|
||
|
{
|
||
|
Formula argument;
|
||
|
};
|
||
|
|
||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
|
||
|
struct Or
|
||
|
{
|
||
|
std::vector<Formula> arguments;
|
||
|
};
|
||
|
|
||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
|
||
|
|
||
|
|
||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endif
|