Questions tagged [parsec]
Parsec is an industrial-strength, monadic parser combinator library for Haskell.
parsec
611
questions
2
votes
1
answer
77
views
How do I parse Python-style chaining operators in Haskell using parsec?
In the project I'm currently working on, I construct the expression parser in parsec. The code is something like:
opTable :: [[Operator Parser Expr]]
opTable =
[
-- ...
[ InfixL $ ...
4
votes
1
answer
101
views
Why does Parsec stop parsing with multiple parser?
I'm trying to write a simple parser in Haskell using Parsec but my input "Hello World" is never correctly parsed.
My code looks like this:
parser = p1 <|> p2
p1 = string "Hello&...
2
votes
1
answer
116
views
Haskell and Parsec: Parsing two separated lists of numbers
I've been experimenting with Parsec for the first time in my life and I found a task that turned out surprisingly difficult.
I want to parse two lists of numbers separated by | character.
Here's an ...
0
votes
1
answer
29
views
Parsec_Compilation_WorkerGroup_Error
WorkerGroup.h:88:5: error: looser throw specifier for 'virtual threads::WorkerGroup::~WorkerGroup() throw (threads::CondException, threads::MutexException)'
88 | ~WorkerGroup();
| ^
...
1
vote
1
answer
61
views
How to extract comments from String using Parsec?
I'm trying to parse just comments from a String and I'm close but not quite there.
import Text.ParserCombinators.Parsec
parseSingleLineComment :: Parser String
parseSingleLineComment = do
string ...
0
votes
0
answers
79
views
What is issue/feature 150 in Parsec?
I am looking through the parsec github repository (currently at version 3.1.16.1) on the master branch. As of the time of writing this, the latest commit on master has commit id ...
0
votes
0
answers
92
views
How do I get the input consumed by a parser in Parsec?
TL;DR: Is there a simple way for me to get the input stream consumed by a parser? Perhaps there is a way using the getInput, getPosition, and parsecMap utilities provided by parsec?
I have a lexer ...
1
vote
1
answer
76
views
Handling infix operator
I'm trying to parse a simple language defined as follows:
import Data.Functor.Identity
import Data.Text (Text)
import qualified Data.Text as T
import Text.Parsec
import qualified Text.Parsec.Expr as ...
0
votes
1
answer
58
views
Using Parsec to parse a string containing a list of tuples
I am trying to parse (using parsec) a string that represents some data type that I defined. Thus the string needs to be parsed to my data type. An example of the string would be,
[(1,[(<,0),(%,4)]),...
2
votes
2
answers
124
views
How can I get from `a -> Parser b` to `Parser (a -> b)`? [duplicate]
I'm trying to update a parsec parser that uses buildExpressionParser from Text.Parsec.Expr. I'm trying (and possibly this is ill-advised, but it looks like it's supposed to be practical) to build part ...
1
vote
1
answer
172
views
Take strings as tokens parsing with Parsec
I am using Parsec library to parse a string. The problem I have is that can't differentiate some tokens because they are words with the same prefix. Simplifying the whole grammar (in my case it's not ...
2
votes
1
answer
127
views
Using makeExprParser with ambiguity
I'm currently encountering a problem while translating a parser from a CFG-based tool (antlr) to Megaparsec.
The grammar contains lists of expressions (handled with makeExprParser) that are enclosed ...
0
votes
2
answers
46
views
How to properly read to stop words with Parsec?
I can't figure out how to read text with parsec to a stop word, I understand that you can do something like this
paramBlockExpr :: Parser ParamBlock
paramBlockExpr = do
p <- paramExpr
txt <- ...
2
votes
2
answers
113
views
Eagerness of separator parser in `sepBy` in Parsec
This is a question pertaining to a more general question of parser precedence in Haskell's Parsec, so feel free to respond with more generality about my problem.
Let's say I have a p :: Parsec String (...
0
votes
2
answers
276
views
How to parse Number with comma via Megaparsec
Currently I have a parser:
pScientific :: Parser Scientific
pScientific = lexeme L.scientific
This is able to easily parse something like 4087.00
but fails when then number 4,087.00 Is there a way to ...