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.

569 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,055
  • 3
  • 18
  • 32
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,901
  • 1
  • 16
  • 29
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
  • 765
  • 4
  • 22
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
  • 9
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
  • 8,208
  • 3
  • 32
  • 69
0
votes
0 answers

Is parsec an alternative of ANTLR?

I 'm planning to create a small programming language for my particular purpose. I read ANTLR3 is good for such an objective. Let me ask whether Parsec is a possible alternative of ANTLR3 or falls in a different category. Thank you very much.
seven_swodniw
  • 811
  • 3
  • 9
  • 15
-1
votes
2 answers

How can I make an if using parsec (Haskell) to verify the input generated by an optional choice?

I have this algebraic datatype: data Arithmetic = Sum Int Int | Mult Int Int deriving (Show) And I want to do this: parseArith :: Parser Arithmetic parseArith = do a <- many1 digit spaces string "+" <|> string "*" spaces b…
NrBanMex
  • 305
  • 2
  • 7
-1
votes
1 answer

How to access Parsecs Input Stream directly

I want to access parsecs input stream directly which can be done using getParserState. To read from the stream the uncons method is provided. However I'm facing (as usual) a type related problem. so this is my parsing function: myParser :: (Stream s…
John Smith
  • 2,110
  • 1
  • 11
  • 20
-1
votes
1 answer

What's a difference between unary and binary operator parsing in Haskell?

I'm learning some techniques to make a very simple Haskell parser that serves to calculation consistence (addition, subtraction and other trivial operations). Library I use is Parsec. Although I've got some comprehension on binary calculation, it…
-1
votes
1 answer

How to overload operator in Parsec/Megaparsec?

I am implementing a compiler using Parsec/Megaparsec as parser. I can't find a way to overload operator +, which I want to use for both integer addition and string concatenation. Is it possible?
sinoTrinity
  • 972
  • 1
  • 12
  • 24
-1
votes
1 answer

How to parse a keyword that is also an operator

I am trying to parse the following code using parsec for x = Int in [1, 2, 3] print x + 1 The only part of the example that might be hard to understand is x = Int which means the variable x is defined as an Int. Syntactically Int here is an…
John Smith
  • 2,110
  • 1
  • 11
  • 20
-1
votes
1 answer

How to parse a Tuple (String,Int) in Haskell using parsec

I think i already managed to parse strings to strings and strings to Ints but I also need to parse a (String,Int) type as userRatings is in order to read from a textFile correctly and I am using Parsec This is the Parsing along with the…
Max
  • 69
  • 7
-2
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,648
  • 14
  • 46
  • 82
-3
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
  • 134
  • 1
  • 3
  • 19
1 2 3
37
38