Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
more ambiguous parser help
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
  4 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 21 2006, 7:20 pm
From: "idade...@gmail.com" <idade...@gmail.com>
Date: Fri, 21 Apr 2006 16:20:24 -0700
Local: Fri, Apr 21 2006 7:20 pm
Subject: more ambiguous parser help
I've got another issue that I can't seem to get pyggy to deal with. I
distilled my problem down to this example. Is there anyway to make this
unambiguous? Here's my lexer and parser:

foo.pyl:

INITIAL:
    ",":            return "COMMA"
    "[[:digit:]]+": return "CONSTANT"

    "[[:blank:]]": return
    "\n":          return

foo.pyg:

expression -> COMMA list COMMA;

list ->
      CONSTANT
    | CONSTANT COMMA CONSTANT
    ;

Conceptually, this should be able to work. If it sees ", 1 ," it should
use the first pattern in "list", and if it sees ", 1 , 2 ," it should
take the second. It looks its getting confused walking down both
posibilites. I was under the impression though that GLR parsers can
handle this situation correctly. Shouldn't it be something like this?

read "COMMA" or error
read "CONSTANT" or error
read "COMMA" or error
read next token. if "$eof$", match with first list branch. if
"CONSTANT" drop first branch and continue checking against second
branch.

Or do I misunderstand GLR parsers? Also, I did try the "nonassoc SHORT
LONG" for matching if-then-else's, but that didn't appear to work. Any
help would be greatly appreciated.

-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 22 2006, 2:13 am
From: Tim Newsham <news...@lava.net>
Date: Fri, 21 Apr 2006 20:13:29 -1000 (HST)
Local: Sat, Apr 22 2006 2:13 am
Subject: Re: more ambiguous parser help

> list ->
>      CONSTANT
>    | CONSTANT COMMA CONSTANT
>    ;

You should specify that the "CONSTANT COMMA CONSTANT" rule be
either right associative or left associative (depending on
your preferences).  This is directly analogous to the "E -> E + E"
example.  "id + id + id" could be parsed either as (id + id) + id
or id + (id + id).  Or in yoru example "c,c,c" could be (c,c),c
or c,(c,c).  If you specify left or right associtiativity one
of these possibilities will be disallowed.

   %left COMMA

> take the second. It looks its getting confused walking down both
> posibilites. I was under the impression though that GLR parsers can
> handle this situation correctly. Shouldn't it be something like this?

Yes, it can.  It would give you an ambiguous parse tree with
all possible parses.

> -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.
idadesub@gmail.com  
View profile  
 More options Apr 22 2006, 2:29 pm
From: "idade...@gmail.com" <idade...@gmail.com>
Date: Sat, 22 Apr 2006 11:29:34 -0700
Local: Sat, Apr 22 2006 2:29 pm
Subject: Re: more ambiguous parser help
So I found that if I move the commas down into the list branch, pyggy
no longer considers the grammar to be ambigous:

expression -> list;

list ->
      COMMA CONSTANT COMMA
    | COMMA CONSTANT COMMA CONSTANT COMMA
    ;

So does pyggy only consider the multiple branches under the same
grammar branch?


    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 23 2006, 2:14 pm
From: Tim Newsham <news...@lava.net>
Date: Sun, 23 Apr 2006 08:14:12 -1000 (HST)
Local: Sun, Apr 23 2006 2:14 pm
Subject: Re: more ambiguous parser help

> So I found that if I move the commas down into the list branch, pyggy
> no longer considers the grammar to be ambigous:

> expression -> list;

> list ->
>      COMMA CONSTANT COMMA
>    | COMMA CONSTANT COMMA CONSTANT COMMA
>    ;

> So does pyggy only consider the multiple branches under the same
> grammar branch?

No.  This is an entirely different grammar which does not have
any ambiguities.

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
©2010 Google