[Gridflow-cvs] [svn] commit: r6328 - in /trunk: doc/flow_classes/#expr-help.pd src/expr.cxx

svn-gridflow at artengine.ca svn-gridflow at artengine.ca
Thu Sep 23 14:56:40 EDT 2010


Author: matju
Date: Thu Sep 23 14:56:36 2010
New Revision: 6328

Log:
add << >> < > <= >= == != && ||

Modified:
    trunk/doc/flow_classes/#expr-help.pd
    trunk/src/expr.cxx

Modified: trunk/doc/flow_classes/#expr-help.pd
==============================================================================
--- trunk/doc/flow_classes/#expr-help.pd (original)
+++ trunk/doc/flow_classes/#expr-help.pd Thu Sep 23 14:56:36 2010
@@ -1,31 +1,35 @@
-#N canvas 0 0 632 406 10;
+#N canvas 467 70 632 446 10;
 #X obj 0 0 doc_h;
-#X obj 3 352 doc_also;
-#X obj 0 372 doc_f;
-#X obj 3 140 doc_c 1..;
-#X obj 14 170 doc_cc any;
-#X obj 97 170 doc_m cany <atom>;
-#X text 232 170 floats and symbols (and commas and semicolons) that
+#X obj 3 392 doc_also;
+#X obj 0 412 doc_f;
+#X obj 3 180 doc_c 1..;
+#X obj 14 210 doc_cc any;
+#X obj 97 210 doc_m cany <atom>;
+#X text 232 210 floats and symbols (and commas and semicolons) that
 will be joined together to form a string which will be interpreted
 in a manner quite similar to what [expr] does.;
-#X obj 3 228 doc_i 1;
-#X obj 14 258 doc_ii 0;
-#X obj 97 258 doc_m i0 bang;
-#X text 232 258 evaluate expression and output result.;
-#X obj 3 290 doc_o 1;
-#X obj 14 320 doc_oo 0;
-#X obj 97 320 doc_m o0 float;
-#X text 232 320 the result.;
-#X obj 103 352 expr;
-#X obj 139 352 expr~;
-#X obj 181 352 fexpr~;
+#X obj 3 268 doc_i 1;
+#X obj 14 298 doc_ii 0;
+#X obj 97 298 doc_m i0 bang;
+#X text 232 298 evaluate expression and output result.;
+#X obj 3 330 doc_o 1;
+#X obj 14 360 doc_oo 0;
+#X obj 97 360 doc_m o0 float;
+#X text 232 360 the result.;
+#X obj 103 392 expr;
+#X obj 139 392 expr~;
+#X obj 181 392 fexpr~;
 #X obj 98 43 #expr;
 #X text 135 43 computes the result of the formula(s) you write in it.
 ;
-#X text 96 62 it supports those infix operators: + - * / & ^ |;
-#X text 96 78 it supports C-like operator precedence \, and the use
+#X text 96 128 it supports C-like operator precedence \, and the use
 of () for overriding operator precedence.;
-#X text 96 107 it supports float literals \, hex literals.;
+#X text 96 157 it supports float literals \, hex literals.;
+#X text 96 62 it supports those infix operators: + - * / & ^ | << >>
+;
+#X text 96 78 and these: == != < <= > >= && ||;
+#X text 118 94 unlike [expr] \, a||b may return non-bool b;
+#X text 118 108 unlike [expr] \, a&&b may return non-bool a;
 #X connect 1 1 15 0;
 #X connect 1 1 16 0;
 #X connect 1 1 17 0;

Modified: trunk/src/expr.cxx
==============================================================================
--- trunk/src/expr.cxx (original)
+++ trunk/src/expr.cxx Thu Sep 23 14:56:36 2010
@@ -39,7 +39,13 @@
 		while (*s && isspace(*s)) s++;
 		if (!*s) tok.a_type=A_NULL;
 		else if (isdigit(*s) || *s=='.') {char *e; tok = strtof(s,&e); s=(const char *)e;}
-		else if (strchr("+-*/%&|^",*s)) {char t[2]={0,0}; *t=*s; tok.a_type=A_OP; tok.a_symbol=gensym(t); s++;}
+		else if (strchr("+-*/%&|^<>",*s)) {
+			char t[3]={0,0,0};
+			t[0]=*s++;
+			if (*s==s[-1] || *s=='=') t[1]=*s++;
+			tok.a_type=A_OP;
+			tok.a_symbol=gensym(t);
+		}
 		else if (*s=='(') {s++; tok.a_type=A_OPEN;}
 		else if (*s==')') {s++; tok.a_type=A_CLOSE;}
 		else if (*s==';') {s++; tok.a_type=A_SEMI;}
@@ -119,8 +125,12 @@
 	#define PR(SYM) priorities[gensym(#SYM)]
 	PR(*) = PR(/) = PR(%) = 5;
 	PR(+) = PR(-) = 6;
+	PR(<<) = PR(>>) = 7;
+	PR(<) = PR(>) = PR(<=) = PR(>=) = PR(==) = PR(!=) = 8;
 	PR(&) = 10;
-	PR(|) = 11;
-	PR(^) = 12;
+	PR(^) = 11;
+	PR(|) = 12;
+	PR(&&) = 13;
+	PR(||) = 14;
 	\startall
 }



More information about the Gridflow-cvs mailing list