Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
b85bfcd
Add calculator class
IzumiSy Jan 3, 2017
0b46785
Modify Makefile
IzumiSy Jan 3, 2017
681d929
Revert
IzumiSy Jan 3, 2017
735222f
Add namespace prefix
IzumiSy Jan 3, 2017
457d1f5
Add calculator.h
IzumiSy Jan 3, 2017
735c54d
Remove a duplicated -Wall option
IzumiSy Jan 3, 2017
9c726e3
Modify
IzumiSy Jan 3, 2017
eaa79ea
Fix
IzumiSy Jan 3, 2017
3776023
Create Calculator instance
IzumiSy Jan 3, 2017
afe68d8
Implement StringExpression class
IzumiSy Jan 3, 2017
71cad09
Lots of modifications
IzumiSy Jan 3, 2017
99b8bbd
Rename SIGN -> SYMBOL
IzumiSy Jan 4, 2017
4b1b054
makeSign is a member function of SYMBOL
IzumiSy Jan 4, 2017
9b70c30
SYMBOL struct has more members
IzumiSy Jan 4, 2017
7c72913
Rename functions
IzumiSy Jan 4, 2017
926abb3
Add this
IzumiSy Jan 4, 2017
ffeaa6c
Add ExpressionList class
IzumiSy Jan 4, 2017
a7cb7e0
Remove processBrackets
IzumiSy Jan 4, 2017
9d8c9dc
Implement skeltons of validators
IzumiSy Jan 4, 2017
8a93cb4
Implement equal operator
IzumiSy Jan 4, 2017
28120d2
Add Exception struct
IzumiSy Jan 4, 2017
a91f58d
Change return variable type
IzumiSy Jan 4, 2017
68bcbfa
Update return variale types
IzumiSy Jan 4, 2017
2e3b062
Use try block
IzumiSy Jan 4, 2017
7326aaf
Update clean task
IzumiSy Jan 4, 2017
1bbe877
Implemt cleanupJunks sand validateDuplicatedSymbol
IzumiSy Jan 4, 2017
1df5a0f
Implement validateLonelySymbol
IzumiSy Jan 4, 2017
71f8924
Fix spacing
IzumiSy Jan 4, 2017
41f1cea
Remove bracket.h and calcurate.h
IzumiSy May 8, 2017
965d8b4
Remove utils.h
IzumiSy May 8, 2017
8efcbd7
Remove unnecessary include
IzumiSy Jul 15, 2017
fbe1188
Merge master
IzumiSy Jul 15, 2017
5de8367
wip
IzumiSy Apr 18, 2019
9631b71
wip
IzumiSy Apr 18, 2019
66218bd
Introduced minunit
IzumiSy Apr 19, 2019
4b65fef
Update gitignore
IzumiSy Apr 19, 2019
846e468
wip
IzumiSy Apr 19, 2019
49ed88a
Added calling run()
IzumiSy Apr 29, 2019
5c9667b
Added unit test for RPN calc
IzumiSy Apr 29, 2019
ade9f5e
This commit will fail
IzumiSy Apr 29, 2019
8dd8aa5
Fix config.yml
IzumiSy Apr 29, 2019
c9bb7a3
Fix again
IzumiSy Apr 29, 2019
b020665
Fix again, again
IzumiSy Apr 29, 2019
6f4113d
Install build-essential
IzumiSy Apr 29, 2019
779e153
Removed sudo
IzumiSy Apr 29, 2019
ed594ea
Run "apt update"
IzumiSy Apr 29, 2019
b593034
Gave some names
IzumiSy Apr 29, 2019
c6859be
Fix
IzumiSy Apr 29, 2019
35a44dc
Fix minunit bug
IzumiSy Apr 29, 2019
d70d267
Makes a bug
IzumiSy Apr 29, 2019
d72807c
Fix the bug
IzumiSy Apr 29, 2019
d6a1eff
Update README
IzumiSy Apr 29, 2019
7d609aa
Fixed README
IzumiSy Apr 29, 2019
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
20 changes: 20 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: 2
jobs:
build:
docker:
- image: debian:stretch

steps:
- checkout
- run:
name: Install deps
command: |
apt update -y
apt install -y build-essential
- run:
name: Test
command: |
cd test
make
./test

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.vscode
mathcalc
core
/*.dSYM
/test/*.dSYM
/test/test
18 changes: 12 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
DBG_OPTS = -O0 -g3 -Wall
SOURCE = mathcalc.cpp
TARGET = mathcalc
SOURCE = mathcalc.cpp \
calculator.cpp \
stringExpression.cpp \
expressionList.cpp \
rpn.cpp

mathcalc: $(SOURCE)
g++ $(DBG_OPTS) -Wall -o $(TARGET) $(SOURCE)
g++ $(DBG_OPTS) -std=c++11 -o $(TARGET) $(SOURCE)

.PHONY: clean run debug release
.PHONY: clean run release
clean:
rm $(TARGET)
rm -r mathcalc.dSYM
$(shell [ -e $(TARGET) ] && rm $(TARGET))
$(shell [ -d $(TARGET).dSYM ] && rm -r $(TARGET).dSYM)
$(shell [ -e core ] && rm core)
@echo Done

run: $(TARGET)
./mathcalc

release: mathcalc.cpp
g++ -Wall -o $(TARGET) $(SOURCE)
g++ -o $(TARGET) $(SOURCE)
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# mathcalc
Simple arithmetic calculater for command-line.
> Simple arithmetic calculater for command-line.

[![CircleCI](https://circleci.com/gh/IzumiSy/mathcalc.svg?style=svg)](https://circleci.com/gh/IzumiSy/mathcalc)

```bash
$ ./mathcalc "1+2+(10*2+(5*2))+10"
> 1+2+(10*2+(5*2))+10
Expand Down
139 changes: 0 additions & 139 deletions bracket.h

This file was deleted.

47 changes: 47 additions & 0 deletions calculator.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <iostream>
#include "calculator.h"
#include "stringExpression.h"

// Parses string expressions of std::string into ExpressionList
void Calculator::parse(std::string expressions) {
StringExpression stringExpression(expressions);

while (1) {
stringExpression.begin();
stringExpression.parseNumberValue();
if (stringExpression.hasNextExpression()) {
stringExpression.parseExpression();
stringExpression.next();
} else {
break;
}
}

this->expressionList = stringExpression.getExpressionsList();
this->expressionList.cleanupJunks();
return;
}

// Prints stringified ExpressionList into STDOUT
void Calculator::print() {
std::cout << this->expressionList.stringify() << std::endl;
return;
}

// Checks out if this->expressionList has any invalid expression, and throws exceptions.
// his method expects to be called after Calculator::parse because this->expressionList is populated by it.
void Calculator::validate() {
this->expressionList.validateBracketsParing();
this->expressionList.validateDuplicatedSymbol();
this->expressionList.validateLonelySymbol();
return;
}

void Calculator::run() {
// TODO: あとでつくる
return;
}
20 changes: 20 additions & 0 deletions calculator.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#ifndef __CALCULATOR_H__
#define __CALCULATOR_H__

#include <string>
#include <list>
#include "expressionList.h"

class Calculator {
private:
ExpressionList expressionList;

public:
void parse(std::string expressions);
void print();
void validate();
void run();
};

#endif // __CALCULATOR_H__

Loading