[Haskell-cafe] Parsec error message not making any sense

Fredrik Karlsson dargosch at gmail.com
Tue Jul 9 08:07:24 CEST 2013


Hi Roman,

I'm using parsec-3.1.3

I put the code in a gist here - sorry about that.

https://gist.github.com/dargosch/5955045

Fredrik




On Tue, Jul 9, 2013 at 12:08 AM, Roman Cheplyaka <roma at ro-che.info> wrote:

> Hi Fredrik,
>
> First, do you use the latest parsec version (3.1.3)? If not, can you try
> the same with 3.1.3?
>
> Second, please upload your code to hpaste.org or a similar service and
> give us the link. It's not much fun to extract code from an html email.
>
> Roman
>
> * Fredrik Karlsson <dargosch at gmail.com> [2013-07-08 23:54:17+0200]
> > Dear list,
> >
> > I have a Parsec parser that fails and gives the following error message:
> >
> > *Main> parseFromFile textgridfile testFile
> > Left
> >
> "/Users/frkkan96/Documents/src/ume/umecore/testing/testdata/testdata.TextGrid"
> > (line 35, column 5):
> > unexpected "t"
> > expecting "intervals ["
> >
> > Now, this is perfectly understandable, but line 35, col 5 in the file
> being
> > parsed looks like the supplies image - there is no 't' there.
> >
> > Any ideas on what is going on?
> >
> > The parser I am using is:
> >
> > data VariableLine = VariableLine String String deriving Show
> > data TierType = IntervalTier | PointTier deriving Show
> >
> > data Tier = Tier String deriving Show
> > data LabelFile = LabelFile Double Double deriving Show
> >
> > data Label = Label String TierType Double Double String deriving Show
> >
> >
> > haskelldef = makeTokenParser haskellDef
> >
> >
> > textgridfile :: Parser (LabelFile, [[Label]])
> > textgridfile = do
> > h <- header
> > ll <- many1 tier
> > return $ (h,ll)
> >
> > header :: Parser LabelFile
> > header = do
> > string headTS1
> > start <- try (float haskelldef)
> > <|> (fmap fromInteger $ integer haskelldef )
> > string "xmax = "
> > end <- try (float haskelldef)
> > <|> (fmap fromInteger $ integer haskelldef )
> > string "tiers? <exists> \n"
> > string "size = "
> > integer haskelldef
> > string "item []:"
> > whiteSpace haskelldef
> > return $ LabelFile start end
> >
> > tier :: Parser [Label]
> > tier = do
> > whiteSpace haskelldef
> > string "item ["
> > integer haskelldef
> > string "]:"
> > whiteSpace haskelldef
> > try (string "class = \"IntervalTier\"")
> > <|> string "class = \"TextTier\""
> > whiteSpace haskelldef
> > string "name = "
> > char '"'
> > name <- many quotedChar
> > char '"' <?> "quote at end of cell"
> > whiteSpace haskelldef
> > string "xmin = "
> > try (float haskelldef) <|> (fmap fromInteger $ integer haskelldef )
> > whiteSpace haskelldef
> > string "xmax = "
> > try (float haskelldef) <|> (fmap fromInteger $ integer haskelldef )
> > string "intervals: size = " <|> string "points: size = "
> > integer haskelldef
> > whiteSpace haskelldef
> > labelList <- many1 (interval name)
> > return $ labelList
> > interval :: String -> Parser Label
> > interval tierName = do
> > whiteSpace haskelldef
> > string "intervals ["
> > integer haskelldef
> > string "]:"
> > whiteSpace haskelldef
> > string "xmin = "
> > start <- try (float haskelldef)
> > <|> (fmap fromInteger $ integer haskelldef )
> > whiteSpace haskelldef
> > string "xmax = "
> > end <- try (float haskelldef)
> > <|> (fmap fromInteger $ integer haskelldef )
> > whiteSpace haskelldef
> > string "text = "
> > char '"'
> > text <- many quotedChar
> > char '"' <?> "quote at end of cell"
> > return $ Label tierName IntervalTier start end text
> >
> > which fails on the attached input file.
> >
> > I can't see how 't' is found?? What am I doing wrong?
> >
> > /Fredrik
> >
> >
> >
> > --
> > "Life is like a trumpet - if you don't put anything into it, you don't
> get
> > anything out of it."
>
>
>
> > _______________________________________________
> > Haskell-Cafe mailing list
> > Haskell-Cafe at haskell.org
> > http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>


-- 
"Life is like a trumpet - if you don't put anything into it, you don't get
anything out of it."
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130709/f1a8a59e/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testdata.TextGrid
Type: application/octet-stream
Size: 3793 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130709/f1a8a59e/attachment-0001.obj>


More information about the Haskell-Cafe mailing list