615 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
2
votes
1
answer
75
views
How to make the entire Parsec parsing process fail upon certain conditions?
I'm creating a toy language in Haskell, and using Text.Parsec to parse everything, So far it's worked great, but there's a certain feature that I don't know how to implement:
What I want to implement: ...
0
votes
1
answer
61
views
Haskell Parsec Parser giving strange error
I am having trouble getting the following code to work. I got it to work originally, then I changed it so all the Nonterminals also have positions. And I added the method parseLexeme that transforms ...
3
votes
1
answer
68
views
Why does my parsec lexer seem to be whitespace sensitive for integers only?
I have a parser that looks like this:
module Parser2 where
import Text.Parsec
import Text.Parsec.String (Parser)
import Text.Parsec.Language (emptyDef)
import qualified Text.Parsec.Expr as Ex
import ...
1
vote
1
answer
115
views
How to turn a function into a parser in haskell (Megaparsec)
This is my current code for multiplying the first and last numbers in a string
type Parser = Parsec Void String
parsefirst :: Parser Int
parsefirst = do
getnotdigits
x <- some digitChar
...
2
votes
1
answer
108
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
133
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
181
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
45
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();
| ^
I ...
1
vote
1
answer
92
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
89
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
116
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
99
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
103
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
149
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
240
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 ...