Giter VIP home page Giter VIP logo

calc's Introduction

calc's People

Contributors

kra53n avatar marcusenok avatar messiac avatar trondinds avatar

Stargazers

 avatar

Watchers

 avatar

calc's Issues

внешний вид

Внешний вид

> operand1 + operand2
; result
; etc

Выход производится по нажатию клавиш Esc или q.

Комментарии

Комментарии будут идти сразу после ;.

Матрицы

> mx(1, 2, 3, 4
     5, 6, 7, 7,
     9, 10, 11, 12,
     13, 14, 15, 16)
; matrix printing
> mx(1, 2, 3, 4
     5, 6, 7, 7,
     9, 10, 11, 12,
    13, 14, 15, 16) +
  mx(1, 2, 3,
     4, 5, 6,
     7, 8, 9)
; matrix sum result

Числа

> 9 + 1
; 10 (0xa, 0o12, 0b1010)

Комплексные числа

Дроби

пример взаимодействия классов

#include <iostream>

using namespace std;

class Interface {
public:
  virtual void print() const = 0;
};

class List : public Interface {
  int data = 1;
public:
  void print() const {
    cout << "hello from list" << '\n';
  }

  int get_data() const {
    return data;
  }
};

class Set : public Interface {
  int data = 0;
public:
  void print() const {
    cout << "hello from set" << '\n';
  }

  int get_data() const {
    return data;
  }

  void add(Interface* interf) {
    List* foo = (List*)interf;
    this->data += foo->get_data();
  }
};


int main() {
  Interface* set = new Set;
  Interface* list = new List;
  set->print();
  list->print();
  printf("The set data before: %d\n", ((Set*)set)->get_data());
  ((Set*)set)->add(list);
  printf("The set data after: %d\n", ((Set*)set)->get_data());
}

Взаимодействие объектов Matrix, Num, ... , будет происходить также, как взаимодействуют List, Set в примере.

архитектура

Архитектура

Классов

  • Lexer
  • Base
    • Matrix
    • int, double
    • Complex
    • BigInteger
    • Fraction

Файлов

xpp означает, что может быть пара файлов hpp и cpp, либо только hpp

  • /src
    • /errors
    • /math
      • Calculatable.xpp
      • Complex.xpp
      • Matrix.xpp
      • BigInt.xpp
      • Fraction.xpp
    • /syntax
      • lex.xpp
      • parse.xpp
      • interp.xpp
    • Cli.xpp
    • Tui.xpp
    • main.cpp

Методы классов

Класс Base

  • result - возвращает строку для печати, метод является чисто виртуальным

Lexer, Parser, Interpreter

Примерный вид интерпретации строки.

interpretate(parse(lex(user_expression))) // return result() - то есть на выходе будет строка

lex

lex -> tokens[]

операции

Операции

  • + - * / ()

Операнды

  • Обычные числа
  • Дроби -> 1 [1/3]
  • Комплексные числа
  • Матрицы
  • BigInteger - вычисление чисел любого размера

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.