X-Git-Url: https://secure.softndesign.org/git/?a=blobdiff_plain;f=parser.h;h=9ce4fd098695f8b0b3f497a82eec664ed375ec66;hb=bdcb95da42ef20e0385e0c0404cb25844c3bb137;hp=8038a9db00c8549bcd2e137d7b7eaed1754c8ca9;hpb=c47a9298fe30c365be65c218c22ca0136b204142;p=calc.git diff --git a/parser.h b/parser.h index 8038a9d..9ce4fd0 100644 --- a/parser.h +++ b/parser.h @@ -1,47 +1,27 @@ #ifndef __PARSER_H__ #define __PARSER_H__ -/* function type */ - -typedef enum { - Val = 0, - Add, Sub, - Mul, Div, Mod, - Pow, Sqr, - Cos, Sin, Atn, - Log, Exp -} func_t; - -/* keyword type */ - -typedef struct _keyword_t { - char *keyword; - func_t func; - int nbops; - int offset; - int prio; -} keyword_t; - -/* calculus element type */ - -#define MAX_OPERANDS 10 -typedef struct _element_t { - func_t func; - int nbops; - struct _element_t *ops[MAX_OPERANDS]; - float value; - int prio; -} element_t; - -#define ERROR_OP ((element_t *)(-1)) +#include "element.h" + +/* global variables */ + +extern double answer; + +/* completion functions */ + +char **generate_completion_list (); + +void free_completion_list (char **list); /* parser function */ +void delelement (element_t *root); + element_t *parser (char *str, char **next, int prio); void print_element (element_t *root, int level); -double evaluate_element (element_t *root); +double evaluate_element (element_t *root, char mask); #endif /* __PARSER_H__ */