Questions tagged [parsec]

Parsec is an industrial-strength, monadic parser combinator library for Haskell.

Parsec is an industrial strength, monadic parser combinator library for Haskell. Parsec lets you construct parsers by combining higher-order Combinators to create larger expressions. Combinator parsers are written and used within the same programming language as the rest of the program. The parsers are first-class citizens of the language , unlike Happy parsers, which must be generated via a preprocessor.

More information about Parsec, including usage examples, can be found on the Parsec website.

609 questions
0
votes
1 answer

Using ParSec integer function to give a Int?

I need to get an Int type from the integer function with Parsec. My code at the moment is aTerm = parens aExpression <|> liftM GetV identifier <|> liftM N integer Where the type of N is N :: Num a => a -> Expr a The error I am…
Shane
  • 2,315
  • 3
  • 21
  • 33
0
votes
1 answer

Why doesn't Parsec allow white spaces before operators in the table for buildExpressionParser

In the code below I can correctly parse white spaces after each of the tokens using Parsec: whitespace = skipMany (space "") number :: Parser Integer number = result "number" where result = do { ds <- many1 digit; whitespace; …
Vanson Samuel
  • 1,953
  • 2
  • 17
  • 30
0
votes
2 answers

Type Problems chaining CaseOf Statements with Parsec

I'm learning haskell, and my current project is writing a parser to read a text file representation of a database. At the moment, I'm setting up the code for reading individual fields of tables. In the text file, fields look either like this: name…
Marshall Conover
  • 855
  • 6
  • 24
0
votes
1 answer

Haskell Stuck at parsing boolean logic

I'm currently writing a parser for a simple programming language. It's getting there however I'm unable to parse a boolean logic statement such as "i == 0 AND j == 0". All I get back is "non exhaustive patterns in case" When I parse a boolean…
user1424720
  • 61
  • 1
  • 10
0
votes
1 answer

Parsing on dates with F#

Are there some 'date parser' library that does for dates what FParsec does to strings ? That is, you either specify rules and it will match against them to recognize the supplied patterns. Conversely, are there any libraries to generate dates…
nicolas
  • 9,549
  • 3
  • 39
  • 83
-1
votes
1 answer

Parsec `try` should backtrack

Isn't Parsec's try supposed to backtrack when it encounters failure? For instance, if I have the code import Control.Applicative ((<|>)) import Debug.Trace import Text.Parsec (try) import Text.Parsec.Combinator (eof) import Text.Parsec.String…
gust
  • 878
  • 9
  • 23
-1
votes
3 answers

Why am I getting a syntax error when using the >>= operator?

Note: I am importing the parsec library, which overloads the >>= (i.e. - __irshift()__) operator. The following Python code: #! /usr/bin/env python # irshift_debug.py from parsec import * def id(x): """Identity parser.""" return…
dbanas
  • 1,707
  • 14
  • 24
-1
votes
1 answer

SQL join using Haskell

I'm a newbie to haskell so some might find this question silly. I'm trying to make a SQL like interpreter using haskell's parsec library.I'm storing data in a Haskell map. To parse the query, the program is split into 2 parts parsing and the…
Lucy
  • 1,812
  • 15
  • 55
  • 93
-2
votes
1 answer

Haskell parsec error

while learning the parsec tutorial , I tried the fllowing command print (Parsec.parse (Parsec.many (Parsec.choice [Parsec.letter,Parsec.spaces ,(Parsec.char ','), Parsec.digit])) "" "hello1 , byebye2 ," ) and the error in console was I am not…
Shaurya
  • 136
  • 1
  • 4
  • 20
1 2 3
40
41