help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GLR ambiguity


From: Alessandro Di Marco
Subject: Re: GLR ambiguity
Date: Thu, 14 Jun 2007 14:46:26 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1.50 (gnu/linux)

Tim Van Holder <address@hidden> writes:

   Alessandro Di Marco wrote:
   > text:
   >      /* empty */
   >    | text sentence
   >    ;
   >
   > sentence:
   >      WORD EOL
   >    | DOUBLEQ WORD EOL
   >    | DOUBLEQ WORD EOL DOUBLEQ
   >    ;

   Well, without a clearer idea of what your grammar is supposed to allow,
   it's hard to suggest ways around this. As it stands now, the parser
   cannot know how to proceed after seeing DOUBLEQ WORD EOL when the next
   token is DOUBLEQ -- that could either initiate a new sentence, or
   terminate the current one, and what's worse, both cases lead to valid
   productions in your example. Your example input ("DOUBLEQ WORD EOL
   DOUBLEQ WORD EOL") can be split into sentences in 2 ways: 2 "DOUBLEQ
   WORD EOL" groupings, or "DOUBLEQ WORD EOL DOUBLEQ" + "WORD EOL".
   So your grammar is broken.

I know. But AFAIK from the bison info, the '%dprec' token should cope with
parser indecisions like that - see "1.5.2 Using GLR to Resolve Ambiguities."

   Your intent seems to be to allow sentences to be quoted; would something
   like this work for you?

   text
   : /* empty */
   | text sentence
   | text DOUBLEQ sentences DOUBLEQ
   ;

   sentences
   : sentence
   | sentences sentence
   ;

Unfortunately not. In american english sentences like the following ones are
quite common:

1) "blah blah blah". Some more blah...
2) "blah blah blah." Some more blah...
3) "blah blah blah.  Some more blah...

Now, the 3rd gives out the problem. For example, here it is an excerpt fooling
my parser:

Party chairwoman Hazel Blears was accused by the Conservatives of scapegoating
immigrants after saying in an Independent on Sunday newspaper interview: "We
have got areas in Salford where private landlords are letting properties with
10 and 12 people in there.  "Now, the community doesn't object to the people -
they object to the exploitation and the fact that that leads to people being on
the street drinking, anti-social behaviour."  Welsh Secretary Peter Hain,
meanwhile accused Home Secretary John Reid of "fanning up" last week's row over
stop-and-question powers possibly being rolled out across the UK.

Alessandro

-- 
A good conscience fears no witness, but a guilty conscience is solicitous even
in solitude. If we do nothing but what is honest, let all the world know
it. But if otherwise, what does it signify to have nobody else know it, so long
as I know it myself? Miserable is he who slights that witness. - Seneca





reply via email to

[Prev in Thread] Current Thread [Next in Thread]