No subject


Thu Feb 24 17:58:36 CET 2011


> numbersP `sepBy` (char '\t')

Or, in your case:

> optionMaybe numbersP `sepBy` char '\t'

(The second solution should have type Parser [Maybe Double])

Although the error given confuses me - I'm not sure why the 'numbersP'
parser should succeed with no input.

Antoine

>
> It type checks, but raises an exception:
>
> Main> parseTest valueP "1\t\t3.3"
> *** Exception: Text.ParserCombinators.Parsec.Prim.many: combinator 'many'=
 is applied to a parser that accepts an empty string.
>
>
> Is there another way to parse Double values?
>
> Thanks a lot so far.
>
> -----Original Message-----
> From: toad3k at gmail.com [mailto:toad3k at gmail.com] On Behalf Of David McBri=
de
> Sent: Monday, August 08, 2011 3:53 PM
> To: Lukasser Stefan (IFAT IMM PSD D TEC / EE)
> Cc: aslatter at gmail.com; beginners at haskell.org
> Subject: Re: [Haskell-beginners] Parse string with optional entries [Pars=
ec]
>
> Read up on the sepBy combinator.
>
> parse (sepBy (many digit) (char ',')) "" "123,321,,2321"
> Right ["123","321","","2321"]
>
> On Mon, Aug 8, 2011 at 7:53 AM, =C2=A0<Stefan.Lukasser-EE at infineon.com> w=
rote:
>> Hi,
>>
>> I have something similar to the CSV-Parser in RWH, chapter 16.
>> The problem are the possible empty cells, i.e. consecutive '\t'-Characte=
rs.
>>
>>
>> -----Original Message-----
>> From: Antoine Latter [mailto:aslatter at gmail.com]
>> Sent: Monday, August 08, 2011 1:44 PM
>> To: Lukasser Stefan (IFAT IMM PSD D TEC / EE)
>> Cc: beginners at haskell.org
>> Subject: Re: [Haskell-beginners] Parse string with optional entries [Par=
sec]
>>
>> On Mon, Aug 8, 2011 at 6:39 AM, =C2=A0<Stefan.Lukasser-EE at infineon.com> =
wrote:
>>> Hi all,
>>>
>>> I'm trying to parse a string in one of the following forms using Parsec=
:
>>>
>>> "1\t1\t123\t456" -> desired output: [Just 1, Just 1, Just 123, Just 456=
]
>>>
>>> or
>>>
>>> "1\t\1\t\t456" =C2=A0-> desired output: [Just 1, Just 1, Nothing, Just =
456]
>>>
>>> i.e., the input is a list of numbers, separated by '\t' characters, wit=
h the possibility of missing entries.
>>> I'm having troubles with the backtracking in case of missing numbers. C=
an anybody give me a hint?
>>>
>>
>> What do you have so far?
>>
>>> Thanks in advance,
>>> Stefan
>>>
>>> _______________________________________________
>>> Beginners mailing list
>>> Beginners at haskell.org
>>> http://www.haskell.org/mailman/listinfo/beginners
>>>
>> _______________________________________________
>> Beginners mailing list
>> Beginners at haskell.org
>> http://www.haskell.org/mailman/listinfo/beginners
>>
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>



More information about the Beginners mailing list