-e
Yikes! Thanks for pointing this out. The precedences are backwards.
Make UNARYMINUS higher precedence than the rest:
cvs diff: Diffing .
Index: pyg_calc.pyg
===================================================================
RCS file: /u1/home/newsham/cvs/pyggy/examples/pyg_calc.pyg,v
retrieving revision 1.1
diff -u -r1.1 pyg_calc.pyg
--- pyg_calc.pyg 2 Jul 2004 05:47:44 -0000 1.1
+++ pyg_calc.pyg 15 Apr 2006 18:44:54 -0000
@@ -2,9 +2,9 @@
code :
names = {}
+%right UNARYMINUS;
%left TIMES DIVIDE;
%left PLUS;
-%right UNARYMINUS;
statement -> NAME EQUALS expression :
names[kids[0]] = kids[2]
And now it works:
calc > 2 + 3 * -5 - -100
87
> -e
Tim Newsham
http://www.lava.net/~newsham/