aboutsummaryrefslogtreecommitdiffstats
path: root/lcd4linux.c
diff options
context:
space:
mode:
authorreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2004-03-06 20:31:16 +0000
committerreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2004-03-06 20:31:16 +0000
commitc008748638679f10746c70a7f677c0e8906ffa9e (patch)
treee8d53c15a9184b19109453e56cf4fc8f8cfac6b0 /lcd4linux.c
parent2f4f59ba2e28ee38f721f09ab6756fd4575b3f78 (diff)
downloadlcd4linux-c008748638679f10746c70a7f677c0e8906ffa9e.tar.gz
[lcd4linux @ 2004-03-06 20:31:16 by reinelt]
Complete rewrite of the evaluator to get rid of the code from mark Morley (because of license issues). The new Evaluator does a pre-compile of expressions, and stores them in trees. Therefore it should be reasonable faster... git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@387 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
Diffstat (limited to 'lcd4linux.c')
-rw-r--r--lcd4linux.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/lcd4linux.c b/lcd4linux.c
index 0f80dad..ab71fdb 100644
--- a/lcd4linux.c
+++ b/lcd4linux.c
@@ -1,4 +1,4 @@
-/* $Id: lcd4linux.c,v 1.66 2004/03/03 04:44:16 reinelt Exp $
+/* $Id: lcd4linux.c,v 1.67 2004/03/06 20:31:16 reinelt Exp $
*
* LCD4Linux
*
@@ -22,6 +22,12 @@
*
*
* $Log: lcd4linux.c,v $
+ * Revision 1.67 2004/03/06 20:31:16 reinelt
+ * Complete rewrite of the evaluator to get rid of the code
+ * from mark Morley (because of license issues).
+ * The new Evaluator does a pre-compile of expressions, and
+ * stores them in trees. Therefore it should be reasonable faster...
+ *
* Revision 1.66 2004/03/03 04:44:16 reinelt
* changes (cosmetics?) to the big patch from Martin
* hash patch un-applied
@@ -569,19 +575,22 @@ int main (int argc, char *argv[])
// maybe go into interactive mode
if (interactive) {
char line[1024];
+ void *tree;
RESULT result = {0, 0.0, NULL};
printf("\neval> ");
for(fgets(line, 1024, stdin); !feof(stdin); fgets(line, 1024, stdin)) {
if (line[strlen(line)-1]=='\n') line[strlen(line)-1]='\0';
if (strlen(line)>0) {
- Eval(line, &result);
- if (result.type==R_NUMBER) {
- printf ("%g\n", R2N(&result));
- } else if (result.type==R_STRING) {
- printf ("'%s'\n", R2S(&result));
+ if (Compile(line, &tree)!=-1) {
+ Eval (tree, &result);
+ if (result.type==R_NUMBER) {
+ printf ("%g\n", R2N(&result));
+ } else if (result.type==R_STRING) {
+ printf ("'%s'\n", R2S(&result));
+ }
+ DelResult (&result);
}
- DelResult (&result);
}
printf("eval> ");
}