Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
pgy_calc.py can't parse "5 - -5"
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
idadesub@gmail.com  
View profile  
 More options Apr 14 2006, 10:49 pm
From: "idade...@gmail.com" <idade...@gmail.com>
Date: Fri, 14 Apr 2006 19:49:48 -0700
Local: Fri, Apr 14 2006 10:49 pm
Subject: pgy_calc.py can't parse "5 - -5"
It looks like the unary minus setup for pgy_calc.pyg doesn't work at
the moment. However, the one for ply does properly parse "5 - -5". Is
there a simple fix for this (since I want to use this kind of grammar
in my code)". Thanks,

-e


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tim Newsham  
View profile  
 More options Apr 15 2006, 2:47 pm
From: Tim Newsham <news...@lava.net>
Date: Sat, 15 Apr 2006 08:47:55 -1000 (HST)
Local: Sat, Apr 15 2006 2:47 pm
Subject: Re: pgy_calc.py can't parse "5 - -5"

On Fri, 14 Apr 2006, idade...@gmail.com wrote:
> It looks like the unary minus setup for pgy_calc.pyg doesn't work at
> the moment. However, the one for ply does properly parse "5 - -5". Is
> there a simple fix for this (since I want to use this kind of grammar
> in my code)". Thanks,

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/

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google