Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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 Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
CC=gcc

CFLAGS= -c -Wall

all: prog

prog: calc.o helpers.o
$(CC) -std=c99 -o prog helpers.o calc.o -lm

calc.o: calc.c
$(CC) $(CFLAGS) calc.c

helpers.o: helpers.c
$(CC) $(CFLAGS) helpers.c

install:
cp ./prog /usr/local/bin
clean:
rm -rf *.o

8 changes: 5 additions & 3 deletions calc.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include <math.h>
#include <string.h>



#include "struct.h"
#include "helpers.h"

Expand Down Expand Up @@ -33,7 +35,7 @@ static struct token* opStack;
static int outCount;
static double* outStack;

static const int binary[] = { 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 };
static const int binary[] = { 1, 1, 1, 1, 1, 1, 0, 0, 0, 0 };
static const int precedence[] = { 0, 0, 1, 1, 1, 2, 3, 4, 4, 5 };
static const int association[] = { 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 };

Expand Down Expand Up @@ -91,7 +93,7 @@ int execute(struct token temp) {
case '%':
result = fmod(d1, d2);
break;
case '#':
case '^':
result = pow(d1, d2);
break;
}
Expand All @@ -106,7 +108,7 @@ int execute(struct token temp) {
d1 = outStack[--outCount];

switch(temp.subType) {
case '_':
case '_':
result = d1;
break;
case '~':
Expand Down