2014-11-27 20:01:06 +01:00
|
|
|
#ifndef NODES_H
|
|
|
|
#define NODES_H
|
|
|
|
|
2014-11-29 00:47:50 +01:00
|
|
|
/*
|
2014-11-29 21:38:52 +01:00
|
|
|
* Monicelli: an esoteric language compiler
|
2014-11-29 00:47:50 +01:00
|
|
|
*
|
|
|
|
* Copyright (C) 2014 Stefano Sanfilippo
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2015-03-05 01:08:47 +01:00
|
|
|
#include "Pointers.hpp"
|
|
|
|
|
2014-12-10 20:38:32 +01:00
|
|
|
#include <functional>
|
|
|
|
#include <unordered_set>
|
2014-11-27 20:01:06 +01:00
|
|
|
|
|
|
|
namespace monicelli {
|
|
|
|
|
2014-11-27 21:53:25 +01:00
|
|
|
enum class Type {
|
|
|
|
INT,
|
|
|
|
CHAR,
|
|
|
|
FLOAT,
|
|
|
|
BOOL,
|
2014-11-30 13:03:45 +01:00
|
|
|
DOUBLE,
|
|
|
|
VOID
|
2014-11-27 21:53:25 +01:00
|
|
|
};
|
2014-11-27 20:01:06 +01:00
|
|
|
|
2014-11-28 20:18:50 +01:00
|
|
|
std::ostream& operator<<(std::ostream &stream, const Type &type);
|
|
|
|
|
2014-11-27 20:01:06 +01:00
|
|
|
|
2014-11-28 19:40:47 +01:00
|
|
|
|
2014-11-27 20:01:06 +01:00
|
|
|
class Emittable {
|
|
|
|
public:
|
|
|
|
virtual void emit(std::ostream &stream, int indent = 0) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class Statement: public Emittable {
|
2014-11-27 23:52:13 +01:00
|
|
|
public:
|
|
|
|
virtual ~Statement() {}
|
2014-11-27 20:01:06 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class SemiExpression: public Emittable {
|
2014-11-27 23:52:13 +01:00
|
|
|
public:
|
|
|
|
virtual ~SemiExpression() {}
|
2014-11-27 20:01:06 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class Expression: public Emittable {
|
2014-11-27 23:52:13 +01:00
|
|
|
public:
|
|
|
|
virtual ~Expression() {}
|
2014-11-27 20:01:06 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
public:
|
2014-11-28 19:32:35 +01:00
|
|
|
};
|
|
|
|
|
2014-11-27 23:52:13 +01:00
|
|
|
|
2014-11-28 19:37:14 +01:00
|
|
|
class StatementList: public PointerList<Statement>, public Emittable {
|
2014-11-28 19:32:35 +01:00
|
|
|
public:
|
2014-11-27 20:01:06 +01:00
|
|
|
virtual void emit(std::ostream &stream, int indent = 0);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template <class T>
|
2014-11-28 19:37:14 +01:00
|
|
|
class ListEmittable: public PointerList<T>, public Emittable {
|
2014-11-27 20:01:06 +01:00
|
|
|
public:
|
|
|
|
virtual void emit(std::ostream &stream, int indent = 0) {
|
|
|
|
if (this->size() > 0) {
|
2014-11-28 19:32:35 +01:00
|
|
|
T *last = this->back(); // TODO wut?
|
|
|
|
for (T *e: *this) {
|
2014-11-27 20:01:06 +01:00
|
|
|
e->emit(stream);
|
|
|
|
if (e != last) {
|
|
|
|
stream << getSeparator();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual std::string getSeparator() const {
|
|
|
|
return ", ";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-11-28 19:32:35 +01:00
|
|
|
class ExpressionList: public ListEmittable<Expression> {
|
2014-11-27 20:01:06 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class SimpleExpression: public Expression {
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class Id: public SimpleExpression {
|
|
|
|
public:
|
2014-11-28 00:01:24 +01:00
|
|
|
explicit Id(std::string *c): value(c) {}
|
2014-11-27 23:52:13 +01:00
|
|
|
virtual ~Id() {}
|
|
|
|
|
2014-11-27 20:01:06 +01:00
|
|
|
virtual void emit(std::ostream &stream, int indent = 0);
|
|
|
|
|
|
|
|
private:
|
2014-11-28 19:40:47 +01:00
|
|
|
Pointer<std::string> value;
|
2014-11-27 20:01:06 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-11-28 19:32:35 +01:00
|
|
|
class IdList: public ListEmittable<Id> {
|
2014-11-27 20:01:06 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class Number: public SimpleExpression {
|
|
|
|
public:
|
|
|
|
virtual void emit(std::ostream &stream, int indent = 0) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class Integer: public Number {
|
|
|
|
public:
|
|
|
|
Integer(long i): value(i) {}
|
|
|
|
virtual void emit(std::ostream &stream, int indent = 0);
|
|
|
|
|
|
|
|
private:
|
|
|
|
long value;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class Float: public Number {
|
|
|
|
public:
|
|
|
|
Float(double f): value(f) {}
|
|
|
|
virtual void emit(std::ostream &stream, int indent = 0);
|
|
|
|
|
|
|
|
private:
|
|
|
|
double value;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class Return: public Statement {
|
|
|
|
public:
|
|
|
|
explicit Return(Expression *e): expression(e) {}
|
|
|
|
virtual void emit(std::ostream &stream, int indent = 0);
|
|
|
|
|
|
|
|
private:
|
2014-11-28 19:40:47 +01:00
|
|
|
Pointer<Expression> expression;
|
2014-11-27 20:01:06 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class Loop: public Statement {
|
|
|
|
public:
|
|
|
|
Loop(StatementList *b, Expression *c): body(b), condition(c) {}
|
|
|
|
virtual void emit(std::ostream &stream, int indent = 0);
|
|
|
|
|
|
|
|
private:
|
2014-11-28 19:40:47 +01:00
|
|
|
Pointer<StatementList> body;
|
|
|
|
Pointer<Expression> condition;
|
2014-11-27 20:01:06 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class VarDeclaration: public Statement {
|
|
|
|
public:
|
|
|
|
VarDeclaration(Id *n, Type t, bool p, Expression *i):
|
|
|
|
name(n), point(p), init(i), type(t) {}
|
|
|
|
virtual void emit(std::ostream &stream, int indent = 0);
|
|
|
|
|
|
|
|
private:
|
2014-11-28 19:40:47 +01:00
|
|
|
Pointer<Id> name;
|
2014-11-27 20:01:06 +01:00
|
|
|
bool point;
|
2014-11-28 19:40:47 +01:00
|
|
|
Pointer<Expression> init;
|
2014-11-27 20:01:06 +01:00
|
|
|
Type type;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class Assignment: public Statement {
|
|
|
|
public:
|
|
|
|
Assignment(Id *n, Expression *v): name(n), value(v) {}
|
|
|
|
virtual void emit(std::ostream &stream, int indent = 0);
|
|
|
|
|
|
|
|
private:
|
2014-11-28 19:40:47 +01:00
|
|
|
Pointer<Id> name;
|
|
|
|
Pointer<Expression> value;
|
2014-11-27 20:01:06 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class Print: public Statement {
|
|
|
|
public:
|
|
|
|
explicit Print(Expression *e): expression(e) {}
|
|
|
|
virtual void emit(std::ostream &stream, int indent = 0);
|
|
|
|
|
|
|
|
private:
|
2014-11-28 19:40:47 +01:00
|
|
|
Pointer<Expression> expression;
|
2014-11-27 20:01:06 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class Input: public Statement {
|
|
|
|
public:
|
|
|
|
explicit Input(Id *v): variable(v) {}
|
|
|
|
virtual void emit(std::ostream &stream, int indent = 0);
|
|
|
|
|
|
|
|
private:
|
2014-11-28 19:40:47 +01:00
|
|
|
Pointer<Id> variable;
|
2014-11-27 20:01:06 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class Abort: public Statement {
|
|
|
|
public:
|
|
|
|
virtual void emit(std::ostream &stream, int indent = 0);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class Assert: public Statement {
|
|
|
|
public:
|
|
|
|
explicit Assert(Expression *e): expression(e) {}
|
|
|
|
virtual void emit(std::ostream &stream, int indent = 0);
|
|
|
|
|
|
|
|
private:
|
2014-11-28 19:40:47 +01:00
|
|
|
Pointer<Expression> expression;
|
2014-11-27 20:01:06 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class FunctionCall: public Statement, public Expression {
|
|
|
|
public:
|
|
|
|
FunctionCall(Id *n, ExpressionList *a): name(n), args(a) {}
|
|
|
|
virtual void emit(std::ostream &stream, int indent = 0);
|
|
|
|
|
|
|
|
private:
|
2014-11-28 19:40:47 +01:00
|
|
|
Pointer<Id> name;
|
|
|
|
Pointer<ExpressionList> args;
|
2014-11-27 20:01:06 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class BranchCase: public Emittable {
|
|
|
|
public:
|
|
|
|
BranchCase(SemiExpression *c, StatementList *b): condition(c), body(b) {}
|
2014-11-28 19:32:35 +01:00
|
|
|
virtual ~BranchCase() {}
|
2014-11-27 20:01:06 +01:00
|
|
|
|
|
|
|
virtual void emit(std::ostream &stream, int indent = 0);
|
|
|
|
private:
|
2014-11-28 19:40:47 +01:00
|
|
|
Pointer<SemiExpression> condition;
|
|
|
|
Pointer<StatementList> body;
|
2014-11-27 20:01:06 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-11-28 19:37:14 +01:00
|
|
|
typedef PointerList<BranchCase> BranchCaseList;
|
2014-11-27 20:01:06 +01:00
|
|
|
|
|
|
|
|
|
|
|
class Branch: public Statement {
|
|
|
|
public:
|
2014-12-02 16:22:03 +01:00
|
|
|
struct Body {
|
|
|
|
public:
|
|
|
|
Body(BranchCaseList *c, StatementList *e = nullptr): cases(c), els(e) {}
|
|
|
|
|
|
|
|
private:
|
|
|
|
Pointer<BranchCaseList> cases;
|
|
|
|
Pointer<StatementList> els;
|
|
|
|
|
|
|
|
friend class Branch;
|
|
|
|
};
|
|
|
|
|
|
|
|
Branch(Id *v, Branch::Body *b): var(v), body(b) {}
|
2014-11-27 20:01:06 +01:00
|
|
|
virtual void emit(std::ostream &stream, int indent = 0);
|
|
|
|
|
|
|
|
private:
|
2014-11-28 19:40:47 +01:00
|
|
|
Pointer<Id> var;
|
2014-12-02 16:22:03 +01:00
|
|
|
Pointer<Branch::Body> body;
|
2014-11-27 20:01:06 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class Main: public Emittable {
|
|
|
|
public:
|
|
|
|
Main(StatementList *s): body(s) {}
|
|
|
|
virtual void emit(std::ostream &stream, int indent = 0);
|
|
|
|
|
|
|
|
private:
|
2014-11-28 19:40:47 +01:00
|
|
|
Pointer<StatementList> body;
|
2014-11-27 20:01:06 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-11-30 13:03:45 +01:00
|
|
|
class FunArg: public Emittable {
|
|
|
|
public:
|
|
|
|
FunArg(Id *n, Type t, bool p): name(n), type(t), pointer(p) {}
|
|
|
|
virtual ~FunArg() {}
|
|
|
|
|
|
|
|
virtual void emit(std::ostream &stream, int indent = 0);
|
|
|
|
|
|
|
|
private:
|
|
|
|
Pointer<Id> name;
|
|
|
|
Type type;
|
|
|
|
bool pointer;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
typedef ListEmittable<FunArg> FunArgList;
|
|
|
|
|
|
|
|
|
2014-11-27 20:01:06 +01:00
|
|
|
class Function: public Emittable {
|
|
|
|
public:
|
2014-11-30 13:03:45 +01:00
|
|
|
Function(Id *n, Type r, FunArgList *a, StatementList *b):
|
|
|
|
name(n), type(r), args(a), body(b) {}
|
2014-11-28 19:15:36 +01:00
|
|
|
virtual ~Function() {}
|
|
|
|
|
2014-11-27 20:01:06 +01:00
|
|
|
virtual void emit(std::ostream &stream, int indent = 0);
|
2014-11-30 13:05:59 +01:00
|
|
|
void emitSignature(std::ostream &stream, int indent = 0);
|
2014-11-27 20:01:06 +01:00
|
|
|
|
|
|
|
private:
|
2014-11-28 19:40:47 +01:00
|
|
|
Pointer<Id> name;
|
2014-11-30 13:03:45 +01:00
|
|
|
Type type;
|
|
|
|
Pointer<FunArgList> args;
|
2014-11-28 19:40:47 +01:00
|
|
|
Pointer<StatementList> body;
|
2014-11-27 20:01:06 +01:00
|
|
|
};
|
|
|
|
|
2014-11-30 13:03:45 +01:00
|
|
|
|
2014-12-10 20:38:32 +01:00
|
|
|
class Module: public Emittable {
|
|
|
|
public:
|
|
|
|
enum Type {
|
|
|
|
SYSTEM, USER
|
|
|
|
};
|
|
|
|
|
|
|
|
Module(const std::string &n, Type s): name(n), type(s) {}
|
|
|
|
virtual ~Module() {}
|
|
|
|
|
|
|
|
bool operator==(const Module &other) const noexcept {
|
|
|
|
return (name == other.name) && (type == other.type);
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t hash() const noexcept {
|
|
|
|
return std::hash<std::string>()(name) ^ std::hash<bool>()(type);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void emit(std::ostream &stream, int indent = 0);
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::string name;
|
|
|
|
Type type;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
namespace std {
|
|
|
|
|
|
|
|
template<>
|
|
|
|
class hash<monicelli::Module> {
|
|
|
|
public:
|
|
|
|
size_t operator ()(const monicelli::Module &e) const noexcept {
|
|
|
|
return e.hash();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace monicelli {
|
|
|
|
|
2014-11-27 20:01:06 +01:00
|
|
|
class Program: public Emittable {
|
|
|
|
public:
|
|
|
|
virtual void emit(std::ostream &stream, int indent = 0);
|
|
|
|
|
|
|
|
void setMain(Main *m) {
|
2014-11-28 19:40:47 +01:00
|
|
|
main = Pointer<Main>(m);
|
2014-11-27 20:01:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void addFunction(Function *f) {
|
|
|
|
functions.push_back(f);
|
|
|
|
}
|
|
|
|
|
2014-12-10 20:38:32 +01:00
|
|
|
void addModule(Module *m) {
|
|
|
|
modules.insert(std::move(*m));
|
|
|
|
delete m;
|
|
|
|
}
|
|
|
|
|
2014-11-27 20:01:06 +01:00
|
|
|
private:
|
2014-11-28 19:40:47 +01:00
|
|
|
Pointer<Main> main;
|
2014-11-28 19:37:14 +01:00
|
|
|
PointerList<Function> functions;
|
2014-12-10 20:38:32 +01:00
|
|
|
std::unordered_set<Module> modules;
|
2014-11-27 20:01:06 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class ExpNode: public Expression {
|
|
|
|
public:
|
|
|
|
ExpNode(Expression *l, Expression *r): left(l), right(r) {}
|
|
|
|
virtual void emit(std::ostream &stream, int indent = 0);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual std::string getSym() = 0;
|
|
|
|
|
|
|
|
private:
|
2014-11-28 19:40:47 +01:00
|
|
|
Pointer<Expression> left;
|
|
|
|
Pointer<Expression> right;
|
2014-11-27 20:01:06 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class ExpLt: public ExpNode {
|
|
|
|
public:
|
|
|
|
ExpLt(Expression *l, Expression *r): ExpNode(l, r) {}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual std::string getSym() {
|
|
|
|
return "<";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class ExpGt: public ExpNode {
|
|
|
|
public:
|
|
|
|
ExpGt(Expression *l, Expression *r): ExpNode(l, r) {}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual std::string getSym() {
|
|
|
|
return ">";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class ExpLte: public ExpNode {
|
|
|
|
public:
|
|
|
|
ExpLte(Expression *l, Expression *r): ExpNode(l, r) {}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual std::string getSym() {
|
|
|
|
return "<=";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class ExpGte: public ExpNode {
|
|
|
|
public:
|
|
|
|
ExpGte(Expression *l, Expression *r): ExpNode(l, r) {}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual std::string getSym() {
|
|
|
|
return ">=";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class ExpPlus: public ExpNode {
|
|
|
|
public:
|
|
|
|
ExpPlus(Expression *l, Expression *r): ExpNode(l, r) {}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual std::string getSym() {
|
|
|
|
return "+";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class ExpMinus: public ExpNode {
|
|
|
|
public:
|
|
|
|
ExpMinus(Expression *l, Expression *r): ExpNode(l, r) {}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual std::string getSym() {
|
|
|
|
return "-";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class ExpTimes: public ExpNode {
|
|
|
|
public:
|
|
|
|
ExpTimes(Expression *l, Expression *r): ExpNode(l, r) {}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual std::string getSym() {
|
|
|
|
return "*";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class ExpDiv: public ExpNode {
|
|
|
|
public:
|
|
|
|
ExpDiv(Expression *l, Expression *r): ExpNode(l, r) {}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual std::string getSym() {
|
|
|
|
return "/";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class ExpShl: public ExpNode {
|
|
|
|
public:
|
|
|
|
ExpShl(Expression *l, Expression *r): ExpNode(l, r) {}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual std::string getSym() {
|
|
|
|
return "<<";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class ExpShr: public ExpNode {
|
|
|
|
public:
|
|
|
|
ExpShr(Expression *l, Expression *r): ExpNode(l, r) {}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual std::string getSym() {
|
|
|
|
return ">>";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class SemiExpNode: public SemiExpression {
|
|
|
|
public:
|
|
|
|
SemiExpNode(Expression *l): left(l) {}
|
|
|
|
virtual void emit(std::ostream &stream, int indent = 0);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual std::string getSym() = 0;
|
|
|
|
|
|
|
|
private:
|
2014-11-28 19:40:47 +01:00
|
|
|
Pointer<Expression> left;
|
2014-11-27 20:01:06 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SemiExpEq: public SemiExpNode {
|
|
|
|
public:
|
|
|
|
SemiExpEq(Expression *l): SemiExpNode(l) {}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual std::string getSym() {
|
|
|
|
return "==";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class SemiExpLt: public SemiExpNode {
|
|
|
|
public:
|
|
|
|
SemiExpLt(Expression *l): SemiExpNode(l) {}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual std::string getSym() {
|
|
|
|
return "<";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class SemiExpGt: public SemiExpNode {
|
|
|
|
public:
|
|
|
|
SemiExpGt(Expression *l): SemiExpNode(l) {}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual std::string getSym() {
|
|
|
|
return ">";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class SemiExpLte: public SemiExpNode {
|
|
|
|
public:
|
|
|
|
SemiExpLte(Expression *l): SemiExpNode(l) {}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual std::string getSym() {
|
|
|
|
return "<=";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class SemiExpGte: public SemiExpNode {
|
|
|
|
public:
|
|
|
|
SemiExpGte(Expression *l): SemiExpNode(l) {}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual std::string getSym() {
|
|
|
|
return ">=";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class SemiExpPlus: public SemiExpNode {
|
|
|
|
public:
|
|
|
|
SemiExpPlus(Expression *l): SemiExpNode(l) {}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual std::string getSym() {
|
|
|
|
return "+";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class SemiExpMinus: public SemiExpNode {
|
|
|
|
public:
|
|
|
|
SemiExpMinus(Expression *l): SemiExpNode(l) {}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual std::string getSym() {
|
|
|
|
return "-";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class SemiExpTimes: public SemiExpNode {
|
|
|
|
public:
|
|
|
|
SemiExpTimes(Expression *l): SemiExpNode(l) {}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual std::string getSym() {
|
|
|
|
return "*";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class SemiExpDiv: public SemiExpNode {
|
|
|
|
public:
|
|
|
|
SemiExpDiv(Expression *l): SemiExpNode(l) {}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual std::string getSym() {
|
|
|
|
return "/";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class SemiExpShl: public SemiExpNode {
|
|
|
|
public:
|
|
|
|
SemiExpShl(Expression *l): SemiExpNode(l) {}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual std::string getSym() {
|
|
|
|
return "<<";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class SemiExpShr: public SemiExpNode {
|
|
|
|
public:
|
|
|
|
SemiExpShr(Expression *l): SemiExpNode(l) {}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual std::string getSym() {
|
|
|
|
return ">>";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|