about summary refs log tree commit diff stats
path: root/util.c
blob: 7d13e3bf7f3f457f8eee6720924f9d85876045fc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include "util.h"
#include <math.h>
#include <string.h>

const char OPERATOR_LIST[] = {
  '+',
  '-',
  '*',
  '/',
  '^',
  0
};

int is_operator(char *s) {
  for (int i = 0; OPERATOR_LIST[i] != 0; i++) {
    if (s[0] == OPERATOR_LIST[i]) return 1;
  }
  return 0;
}

TYPE discriminate(char *s) {
  if (is_operator(s)) {
    return OPERATOR;
  } else return FUNCTION;
}