Finished trie, started rpn
parent
6a99fb07d1
commit
d54692a622
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* rpn.c: evalutor of RPN formulas
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <syslog.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "rpn.h"
|
||||
#include "trie.h"
|
||||
|
||||
// Growing stack implementation
|
||||
struct grow {
|
||||
struct trie_retval *arr;
|
||||
int64_t elems;
|
||||
int64_t alloc;
|
||||
}
|
||||
|
||||
static struct grow *grow_init(void) {
|
||||
struct grow *g = malloc(sizeof(struct grow));
|
||||
if (g == NULL) {
|
||||
syslog(cfg_log_facility | LOG_ERR, "rpn: Could not initialize growing array: %m");
|
||||
return NULL;
|
||||
}
|
||||
g -> arr = NULL;
|
||||
g -> elems = 0;
|
||||
g -> alloc = 0;
|
||||
return g;
|
||||
}
|
||||
|
||||
static bool grow_push (int64_t val, struct grow *stack) {
|
||||
if (stack -> alloc <= stack -> elems) {
|
||||
stack
|
||||
}
|
||||
}
|
||||
|
||||
bool rpn_eval (char rpn[]) {
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
/*
|
||||
* rpn.h: a header file for rpn.c
|
||||
*/
|
||||
|
||||
#ifndef RPN_H
|
||||
#define RPN_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
bool rpn_eval (char rpn[]);
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue