Skip to main content
OverflowAI is here! AI power for your Stack Overflow for Teams knowledge community. Learn more

Questions tagged [parsec]

Parsec is a parser library for the Haskell programming language.

Filter by
Sorted by
Tagged with
3 votes
2 answers
941 views

CodeWars - Three-pass compiler for arithmetic expressions

I'm looking for feedback on my solution to the Tiny Three-Pass Compiler kata on CodeWars. The kata is to implement a compiler for an arithmetic language in three passes - parsing to an AST, constant ...
DylanSp's user avatar
  • 203
1 vote
1 answer
85 views

Mail merge (Parsec string formatting) example

My intent is to perform "mail merge" where I can write strings like "hi <<name>>" and format them according to a ...
Josh.F's user avatar
  • 187
3 votes
1 answer
327 views

Haskell Parsec library implementation in Scala

I've been developing a compiler for a programming language I'm working on in Scala, and after having used Haskell's Parsec a lot for this sort of thing in the past I decided to reimplement the library ...
J_mie6's user avatar
  • 479
1 vote
1 answer
89 views

Inefficient Parsec parser to skip unreachable block

In a parser written with Parsec 3.1.11, I have a performance issue with parsing (or better, skipping) the unreachable branch of a if-then-else statement. The syntax to be parsed is as follows: ...
cornuz's user avatar
  • 156
4 votes
1 answer
365 views

Haskell Parsec parser of Verilog-style number literals

I've set myself the task to write a function that parses Verilog-style number literals. In Verilog, numbers are written like this: 8'b10101100, ...
mcmayer's user avatar
  • 183
4 votes
1 answer
130 views

Multiple base numbers parser

This code is a Parser that parses numbers according to R5RS. #b1001 - binary #o2127 - octal #h02d - hexadecimal #d1231 - decimal 3923 - decimal It is working ...
lhahn's user avatar
  • 141
3 votes
0 answers
415 views

Haskell s-expression parser and quasiquoter

There are a number of questions on this site about s-expression parsing: e.g., Calculator parsing S-expressions and Code from "Write Yourself a Scheme in 48 Hours" tutorial. However, these ...
wchargin's user avatar
  • 1,169
5 votes
1 answer
658 views

Python tokenizer in Haskell + Parsec

I wrote a tokenizer/lexer (difference?) for Python in Haskell: this is my code on GitHub. I already tested it out with some of CPython's standard library scripts, and it doesn't fail. However, it ...
Gabriel Garcia's user avatar
2 votes
1 answer
87 views

Parsing a component of a regex followed by an optional quantifier character

I have a piece of parsec code that parses a unit optionally followed by ?, + or ...
akonsu's user avatar
  • 273
3 votes
1 answer
168 views

Parsing characters with parsec

I am trying to parse escape sequences as well as plain characters. Can this be made more succinct? ...
akonsu's user avatar
  • 273
3 votes
0 answers
108 views

Generation and parsing of English numerals (cardinal and ordinal)

I need to use the English numerals (American) in Haskell, so I looked for a library that did it. I have not found one, therefore I developed the program that I am presenting here. There are actually ...
Alberto Capitani's user avatar
1 vote
1 answer
74 views

Parsec for primes and fibs

I decided to spend some time working with parsec. I've written some code to check for primality and for whether something is a Fibonacci number. I'm mainly hoping for feedback on readability, but if ...
genisage's user avatar
  • 156
1 vote
1 answer
249 views

Assorted Date Parser

I've written a date parser that parses different types of dates using Parsec. Credit for the original problem goes to here. The following formats are as such: ...
wei2912's user avatar
  • 1,233
5 votes
1 answer
350 views

Using Parsec for simple arithmetic language

I've been reading Types and Programming Languages and I wanted to try to implement the first language in Haskell to understand it properly I have barely written any Haskell before and not used Parsec ...
Brendanator's user avatar
1 vote
1 answer
489 views

block comment parser implementation for "monadic parser combinators"

I'm reading monadic parser combinators. On the page 23, they leave an exercise for defining a Gofer block comment parser, and I try to implement it in Haskell. My code is here: ...
Javran's user avatar
  • 591
6 votes
1 answer
1k views

Using Parsec for lexing&parsing

I'm creating list of Tokens from input [Char] stream using Parsec v3. The definition of Token...
arrowd's user avatar
  • 326
15 votes
2 answers
6k views

Parsing strings with escaped characters using Parsec

I have been working through the exercises in a Write Yourself a Scheme in 48 Hours/Parsing and hacked together something to get parseString to comprehend escaped characters. Also had some inspiration ...
sh54's user avatar
  • 283
6 votes
2 answers
925 views

INI File Parser in Haskell

I'm learning Haskell at the moment, and have just written my first useful module - a parser fo INI files. I used Parsec. I'd like to know what can be improved here - or maybe I did some things ...
user avatar
8 votes
1 answer
846 views

First attempt at a SVG parser

I figured it's about time to jump into some Haskell, so here's a first attempt at an oddly specific SVG parser: ...
Inaimathi's user avatar
  • 2,173