X-Git-Url: http://git.jankratochvil.net/?p=nethome.git;a=blobdiff_plain;f=src%2Fev.c;fp=src%2Fev.c;h=0000000000000000000000000000000000000000;hp=0ce6142e6c540b645fbd69871eb78f79918da002;hb=b1e409dfd348069b8edd942314dee0f3b757c8ac;hpb=e547b1534d6081e9848de4815d441e0cd913a890 diff --git a/src/ev.c b/src/ev.c deleted file mode 100644 index 0ce6142..0000000 --- a/src/ev.c +++ /dev/null @@ -1,137 +0,0 @@ -#include -#include -#include -#include - -#define NDEBUG - -#define BUFSIZE 1024 - -#define bail(arg...) do { fprintf(stderr, ##arg); exit(EXIT_FAILURE); } while (0) - -char *arg; - -int istack[BUFSIZE]; -char opstack[BUFSIZE]; -int istackp,opstackp; - -#ifdef NDEBUG -#define dump(x) -#else -static void dump(char *pref) -{ -int i; - fprintf(stderr,"%s: i[",pref); - for (i=0;i=mypri) - evalit(); - if (!op) return; - if (op==')') { - if (!opstackp || opstack[opstackp-1]!='(') - bail("Not enough content for brackets-inside space!\n"); - opstackp--; - return; - } - if (opstackp>=BUFSIZE) bail("Too many operators (%d is max)!\n",BUFSIZE); - opstack[opstackp++]=op; -} - -static void process(void) -{ -char lastop,op; -int curi; - - istackp=opstackp=0; - for (lastop=0;;lastop=op) switch (op=lex(&curi)) { - case 'n': - if (lastop=='n') bail("Two successive numbers not permitted!\n"); - if (istackp>=BUFSIZE) bail("Too many operators (%d is max)!\n",BUFSIZE); - istack[istackp++]=curi; - break; - case '(': - if (lastop=='n') bail("Open-bracket not permitted after number!\n"); - pushop(op); - break; - case '+': case '-': case '*': case '/': case ')': pushop(op); break; - case 0: - pushop(op); - if (istackp!=1||opstackp) - bail("Machine not in sane state on the end of expression, ints=%d,ops=%d!\n",istackp,opstackp); - printf("%d\n",istack[0]); - return; - default: assert(0); - } -} - -int main(int argc,char **argv) -{ -int argn; - for (argn=1;argn