Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
80884d8
draft of classes
milenanedeljkovic Nov 9, 2021
9010f5b
Update ast.hpp
milenanedeljkovic Nov 9, 2021
1b26506
Delete Mina_Goranovic.txt
elena-mrdja Nov 14, 2021
b0a12b2
Create reports.md
elena-mrdja Nov 14, 2021
5f67119
Update ast.hpp
milenanedeljkovic Nov 14, 2021
8e12fc0
Setters and Getters of classes
mattea777 Nov 14, 2021
67b7d56
adding get() and set() to Expression in ast.hpp
Evdokia-Gneusheva Nov 14, 2021
3b56937
Merge branch 'Workspace' of https://github.com/elena-mrdja/Algorithm-…
Evdokia-Gneusheva Nov 14, 2021
7ce43d4
I fixed one synax error in get() method of bin_Op class
Evdokia-Gneusheva Nov 14, 2021
0394403
Added custom classes and mainwindow
elena-mrdja Nov 14, 2021
b12b5c3
Merge branch 'Workspace' of https://github.com/elena-mrdja/Algorithm-…
elena-mrdja Nov 14, 2021
bcedd85
Setters and getters of AST classes.
daryatodoskova Nov 14, 2021
3e47295
Merge branch 'main' into Workspace
elena-mrdja Nov 14, 2021
9a06766
Practice writing interpreter
mattea777 Nov 15, 2021
2da4b25
Update ast.hpp
milenanedeljkovic Nov 15, 2021
be4692d
Merge branch 'Workspace' of https://github.com/elena-mrdja/Algorithm-…
mattea777 Nov 15, 2021
01c8aa0
Added cache to AST and Block
mattea777 Nov 15, 2021
4128555
Update ast.hpp
daryatodoskova Nov 15, 2021
1e34751
Merge branch 'zorkotdasha-patch-2' into Workspace
Nov 16, 2021
a488cf4
added references and corrected bugs
milenanedeljkovic Nov 16, 2021
b6a923c
added shapes to the viewer
elena-mrdja Nov 17, 2021
da32376
varcell should be scrollable, but there is a bug to be fixed
goranovic37 Nov 17, 2021
3010208
Merge branch 'Workspace' of https://github.com/elena-mrdja/Algorithm-…
goranovic37 Nov 18, 2021
2f40448
line missing
goranovic37 Nov 18, 2021
c74361c
Deleted unnecessary code
mattea777 Nov 18, 2021
e8e1eab
evdokia + milena + dasha changes
milenanedeljkovic Nov 18, 2021
10e3773
dasha + milena + evdokia changes
milenanedeljkovic Nov 18, 2021
37a3af0
dasha + milena + evdokia changes
milenanedeljkovic Nov 18, 2021
5d19385
fixed qt mainwindow SetUp
elena-mrdja Nov 18, 2021
8a1847b
Added individual hpp/cpp files for every class
mattea777 Nov 18, 2021
426309e
Merge branch 'Workspace' of https://github.com/elena-mrdja/Algorithm-…
mattea777 Nov 18, 2021
aeb47ee
Merge branch 'mattea777-patch-1' into Workspace
mattea777 Nov 18, 2021
a4e7d4a
Merge branch 'milenanedeljkovic-patch-2' into Workspace
mattea777 Nov 18, 2021
51470ac
Merge pull request #27 from elena-mrdja/Workspace
mattea777 Nov 18, 2021
84aa5f4
Create week 3 - personal report
milenanedeljkovic Nov 21, 2021
6c8c3bc
Update ast.hpp
Evdokia-Gneusheva Nov 21, 2021
3b7aa5e
Update project_design.md
goranovic37 Nov 22, 2021
fef3159
Update reports.md
goranovic37 Nov 22, 2021
1d06ee2
setting up varcell
goranovic37 Nov 22, 2021
a128c6d
edited comments, added number.hpp
Nov 22, 2021
ef80796
Merge branch 'Workspace' of https://github.com/elena-mrdja/Algorithm-…
Nov 22, 2021
2d22ce8
number + comment changes
Nov 22, 2021
8bbfe3f
changed variable and declaration. only shifted attributes around but …
Nov 22, 2021
3592f43
I added method which insert variable to a list of variables
Evdokia-Gneusheva Nov 22, 2021
e9e12e7
virtual methods (still empty) for Dasha
milenanedeljkovic Nov 25, 2021
b34c19d
get_num_value in number.hpp and virtual classes in expression.hpp
Nov 25, 2021
28344eb
Merge branch 'Workspace' of https://github.com/elena-mrdja/Algorithm-…
Nov 25, 2021
ecce1e9
Create .DS_Store
daryatodoskova Nov 25, 2021
f068850
Merge branch 'Workspace' of https://github.com/elena-mrdja/Algorithm-…
daryatodoskova Nov 25, 2021
f0eb7f4
Merge branch 'Workspace' of https://github.com/elena-mrdja/Algorithm-…
Evdokia-Gneusheva Nov 26, 2021
953fb8b
new files: tried creating templates for Expression and Variable; rena…
Nov 27, 2021
38c75fa
Merge branch 'Workspace' of https://github.com/elena-mrdja/Algorithm-…
Nov 27, 2021
a4bf24f
just some part of updated BinOp but I am struggling with it
Nov 28, 2021
60d414d
Merge pull request #28 from elena-mrdja/Workspace
milenanedeljkovic Nov 28, 2021
7bcbd5b
separating each operation; in progress
milenanedeljkovic Dec 5, 2021
a083c50
final(ish) version of Variable
milenanedeljkovic Dec 5, 2021
872f7c5
changes for the last commits of Variable and BinOp
milenanedeljkovic Dec 5, 2021
6ef42b1
oops
milenanedeljkovic Dec 5, 2021
ca6af18
checking whether the condition is true
milenanedeljkovic Dec 5, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
19 changes: 19 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"configurations": [
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"macFrameworkPath": [
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks"
],
"compilerPath": "/usr/bin/clang",
"cStandard": "c17",
"cppStandard": "c++98",
"intelliSenseMode": "macos-clang-x64"
}
],
"version": 4
}
66 changes: 66 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"files.associations": {
"__bit_reference": "cpp",
"__config": "cpp",
"__debug": "cpp",
"__errc": "cpp",
"__functional_base": "cpp",
"__hash_table": "cpp",
"__locale": "cpp",
"__mutex_base": "cpp",
"__node_handle": "cpp",
"__nullptr": "cpp",
"__split_buffer": "cpp",
"__string": "cpp",
"__threading_support": "cpp",
"__tree": "cpp",
"__tuple": "cpp",
"algorithm": "cpp",
"array": "cpp",
"atomic": "cpp",
"bit": "cpp",
"bitset": "cpp",
"cctype": "cpp",
"chrono": "cpp",
"cmath": "cpp",
"complex": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"exception": "cpp",
"functional": "cpp",
"initializer_list": "cpp",
"ios": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"iterator": "cpp",
"limits": "cpp",
"locale": "cpp",
"map": "cpp",
"memory": "cpp",
"mutex": "cpp",
"new": "cpp",
"optional": "cpp",
"ostream": "cpp",
"ratio": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"string": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"typeinfo": "cpp",
"unordered_map": "cpp",
"utility": "cpp",
"vector": "cpp"
}
}
6 changes: 6 additions & 0 deletions Algorithm-visualizer/AST/assignment.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "assignment.hpp"

Assignment::Assignment()
{

}
63 changes: 63 additions & 0 deletions Algorithm-visualizer/AST/assignment.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#include "ast.hpp"
#include "statement.hpp"
#include "expression.hpp"
#ifndef ASSIGNMENT_HPP
#define ASSIGNMENT_HPP

//enum var_type {
// unknown_var_type = 0,
// string = 1,
// integer = 2,
// character = 3,
// floating_point = 4

//};

//enum un_op {
// unknown_un_op = 0,
// negation = 1,
// plusplus = 2
// //inverse = 2 (if we add this as a unary operation for number -> -number)
//};

//enum bin_op {
// unknown_bin_op = 0,
// conjunction = 1,
// disjunction = 2,
// addition = 3,
// subtraction = 4,
// multiplication = 5,
// division = 6,
// lthan = 7,
// mthan = 8,
// leq = 9,
// meq = 10,
// eq = 11,
// eqeq = 12
//};

//enum jump_type {
// unknown_jump_type = 0,
// br = 1,
// cont = 2
//};
//enum expression_type {
// unknown_expression_type = 0
//};


class Assignment : public Statement {
public:
Assignment();
~Assignment();
Expression* get_value(){return value;};
void set_value(Expression* v){value= v;}
std::string get_name(){return name;};
void set_name(std::string n){name= n;}
//x = 5; x = y
std::string get_subtype(){return "Assignment";};
private:
std::string name;
Expression* value;
};
#endif // ASSIGNMENT_HPP
60 changes: 44 additions & 16 deletions Algorithm-visualizer/AST/ast.hpp
Original file line number Diff line number Diff line change
@@ -1,29 +1,57 @@
#ifndef AST_H
#define AST_H

#include <string>
#include <iostream>
#include <QAbstractItemModel>
using namespace std;

class AST : public QAbstractItemModel
{
Q_OBJECT
enum un_op {
unknown_un_op = 0,
negation = 1,
plusplus = 2
//inverse = 2 (if we add this as a unary operation for number -> -number)
};

public:
explicit AST(QObject *parent = nullptr);
enum bin_op {
unknown_bin_op = 0,
conjunction = 1,
disjunction = 2,
addition = 3,
subtraction = 4,
multiplication = 5,
division = 6,
lthan = 7,
mthan = 8,
leq = 9,
meq = 10,
eq = 11,
eqeq = 12
};

// Header:
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
enum jump_type {
unknown_jump_type = 0,
br = 1,
cont = 2

// Basic functionality:
QModelIndex index(int row, int column,
const QModelIndex &parent = QModelIndex()) const override;
QModelIndex parent(const QModelIndex &index) const override;
};
enum expression_type {
unknown_expression_type = 0

int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
};

QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;

private:
//AST CLASS

class AST {
protected : AST();
protected : ~AST();
virtual std::string get_type() = 0; // Statement or Expression (this is an abstract method which will be defined in subclasses Statement
//and Expression and inherited by every other subclass below)
virtual std::string get_subtype() = 0; // Block, Declaration, UnOp, BinOp, ...
//(this is an abstract method which will be defined in subclasses Block, Declaration, ...)
};

#endif // AST_H


#endif
6 changes: 6 additions & 0 deletions Algorithm-visualizer/AST/binop.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "binop.hpp"

BinOp::BinOp()
{

}
143 changes: 143 additions & 0 deletions Algorithm-visualizer/AST/binop.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
#include "expression.hpp"
#include "ast.hpp"
#ifndef BINOP_HPP
#define BINOP_HPP

class Addition : public Expression {
public : Addition();
public : ~Addition();
public : double get_value(){
if (left_exp->get_exp_type() == "bool" or right_exp->get_exp_type() == "bool") {return 0;};
return left_exp->get_value() + right_exp->get_value();
};
private :
Expression* left_exp;
Expression* right_exp;
};

class Subtraction : public Expression {
public : Subtraction();
public : ~Subtraction();
public : double get_value(){
if (left_exp->get_exp_type() == "bool" or right_exp->get_exp_type() == "bool") {return 0;};
return left_exp->get_value() - right_exp->get_value();
};
private :
Expression* left_exp;
Expression* right_exp;
};

class Multiplication : public Expression {
public : Multiplication();
public : ~Multiplication();
public : double get_value(){
if (left_exp->get_exp_type() == "bool" or right_exp->get_exp_type() == "bool") {return 0;};
return left_exp->get_value() * right_exp->get_value();
};
private :
Expression* left_exp;
Expression* right_exp;
};

class Division : public Expression {
public : Division();
public : ~Division();
public : double get_value(){
if (left_exp->get_exp_type() == "bool" or right_exp->get_exp_type() == "bool" or right_exp->get_value() == 0) return 0;
return left_exp->get_value() / right_exp->get_value();
};
private :
Expression* left_exp;
Expression* right_exp;
};

class Mthan : public Expression {
public : Mthan();
public : ~Mthan();
public : double get_value(){
if (left_exp->get_exp_type() == "bool" or right_exp->get_exp_type() == "bool") return 0;
if (left_exp->get_value() > right_exp->get_value()) return 1;
return 0;
};
private :
Expression* left_exp;
Expression* right_exp;
};

class Lthan : public Expression {
public : Lthan();
public : ~Lthan();
public : double get_value(){
if (left_exp->get_exp_type() == "bool" or right_exp->get_exp_type() == "bool") return 0;
if (left_exp->get_value() < right_exp->get_value()) return 1;
return 0;
};
private :
Expression* left_exp;
Expression* right_exp;
};

class Leq : public Expression {
public : Leq();
public : ~Leq();
public : double get_value(){
if (left_exp->get_exp_type() == "bool" or right_exp->get_exp_type() == "bool") return 0;
if (left_exp->get_value() <= right_exp->get_value()) return 1;
return 0;
};
private :
Expression* left_exp;
Expression* right_exp;
};

class Meq : public Expression {
public : Meq();
public : ~Meq();
public : double get_value(){
if (left_exp->get_exp_type() == "bool" or right_exp->get_exp_type() == "bool") return 0;
if (left_exp->get_value() >= right_exp->get_value()) return 1;
return 0;
};
private :
Expression* left_exp;
Expression* right_exp;
};

class Eqeq : public Expression {
public : Eqeq();
public : ~Eqeq();
public : double get_value(){
if (left_exp->get_value() == right_exp->get_value()) return 1;
return 0;
};
private :
Expression* left_exp;
Expression* right_exp;
};

class AndOp : public Expression {
public : AndOp();
public : ~AndOp();
public : double get_value(){
if (left_exp->get_value() && right_exp->get_value()) return 1;
return 0;
};
private :
Expression* left_exp;
Expression* right_exp;
};

class OrOp : public Expression {
public : OrOp();
public : ~OrOp();
public : double get_value(){
if (left_exp->get_value() || right_exp->get_value()) return 1;
return 0;
};
private :
Expression* left_exp;
Expression* right_exp;
};


#endif // BINOP_HPP
6 changes: 6 additions & 0 deletions Algorithm-visualizer/AST/binop_template.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "binop_template.hpp"

binop_template::binop_template()
{

}
Loading