Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
help with an ambiguous grammar
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 17 2006, 3:09 am
From: "idade...@gmail.com" <idade...@gmail.com>
Date: Mon, 17 Apr 2006 07:09:27 -0000
Local: Mon, Apr 17 2006 3:09 am
Subject: help with an ambiguous grammar
Hello again,

I'm trying to write a grammar that allows for space separated lists.
Here's my grammar:

%right NEG;
%left MINUS;
%nonassoc SHORT;
%nonassoc LONG;

expression ->
      %prec(MINUS) expression SUB expression
    | %prec(NEG) SUB expression
    | CONSTANT
    | %prec(LONG) LPAREN expression (expression)* RPAREN
    | %prec(SHORT) LPAREN expression RPAREN
    ;

What I want is for something like this: "[1 - 2]" to be parsed to the
python form of [(1-2)], not [1, -2]. However, I can't seem to get this
to be unambiguous. For a more complicated example: this: "[1 2 3 - 4 5
- - 6]" should be parsed as this: [1,2,(3-4),(5 - (-6))]. Any idea how
I can get this grammar to work? Thanks again,

-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 17 2006, 4:46 pm
From: Tim Newsham <news...@lava.net>
Date: Mon, 17 Apr 2006 10:46:17 -1000 (HST)
Local: Mon, Apr 17 2006 4:46 pm
Subject: Re: help with an ambiguous grammar

I think the best solution here is to require parenthesis around unary
minus or to use a seperator other than space (ie. comma).

If you still want to implement your parsing scheme, you can have it
parse all ambiguous alternatives and then filter out the ones you
don't want in post-processing.

> -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