[Haskell-cafe] Re: Parsec is being weird at me

Andrew Coppin andrewcoppin at btinternet.com
Sat Aug 25 16:04:55 EDT 2007


Stefan O'Rear wrote:
> On Sat, Aug 25, 2007 at 08:18:29PM +0100, Andrew Coppin wrote:
>   
>> But hang on a minute...
>>
>> "many" parses 0 or more occurrances of an item.
>>
>> "sepBy" parses 0 or more occurrances of an item, seperated by another item.
>>
>> "endBy" parses 0 or more occurrances of an item, terminated by another 
>> item.
>>
>> "sepEndBy" parses 0 or more occurrances of an item, seperated *and* 
>> terminated by another item.
>>
>> ...except that "endBy" doesn't seem to be working right. :-S
>>     
>
> There is one other little bit of documented behavior.  Parsec's normal
> combinators only parse LL(1) grammars.  Consult any work on formal
> languages for the exact meaning and all the consequences, however for
> this example it serves to note that after seeing abc, the single
> character of lookahead '#' is not sufficient to determine the correct
> parse.
>   

Heh. Starting to wish I had a significantly higher IQ...

I thought the whole *purpose* of the endBy combinator was to keep 
applying one parser until the other one succeeds?

In the example I posted, the two parsers are quite trivial. But in the 
real problem I actually want to solve, they are very non-trivial...



More information about the Haskell-Cafe mailing list