Questions tagged [attoparsec]

A fast Haskell library for parsing ByteStrings

https://github.com/bos/attoparsec

131 questions
0
votes
1 answer

Multi-line *non* match with attoparsec

I was playing around with parsing (PostgreSQL) logs which can have entries that are multi-line. 2016-01-01 01:01:01 entry1 2016-01-01 01:01:02 entry2a entry2b 2016-01-01 01:01:03 entry3 So - with a Perl or Python script I'd just grab the next…
Richard Huxton
  • 21,516
  • 3
  • 39
  • 51
0
votes
1 answer

Attoparsec optional parser with Maybe result

I have an Attoparsec parser like this: myParser :: Parser Text myParser = char '"' *> takeWhile (not . isspace) <* char '"' I want to make this parser optional so I get a function that returns Just txt if the parser matches and Nothing else, i.e. a…
Uli Köhler
  • 13,012
  • 16
  • 70
  • 120
0
votes
1 answer

attoparsec: succeeding on part of the input instead of failing

I have an attoparsec parser, and tests for it, what annoys me is that if I comment part of the parser and run the tests, the parser doesn't return Left "parse error at line ..." but instead I get Right []. Note that I'm using parseOnly to make it…
Emmanuel Touzery
  • 9,008
  • 3
  • 65
  • 81
0
votes
1 answer

Conduit and Attoparsec - extracting delimited text

Say I have a document with text delimited by Jade-style brackets, like {{foo}}. I've written an Attoparsec parser that seems to extract foo properly: findFoos :: Parser [T.Text] findFoos = many $ do manyTill anyChar (string "{{") manyTill letter…
Athan Clark
  • 3,886
  • 2
  • 21
  • 39
0
votes
1 answer

Manually terminate inputs for Conduit Attoparsec

I am processing a syslog logfile, each line as an individual syslog entry, and parsing that entry using a Attoparsec parser. So I am using fileToBS :: IO Handle -> C.Source (ResourceT IO) BS.ByteString fileToBS handleMaker = source C.$=…
xrl
  • 2,155
  • 5
  • 26
  • 40
0
votes
1 answer

Haskell parse list of integers with Attoparsec

I need some help parsing a list of comma delimited integers from a file, when the list of integers can be any length. The string might look like "1,2,3,4,5,6,7,8,..." and the list I need made would be like [1,2,3,4,5,6,7,8,...]. The file format…
user3638162
  • 421
  • 1
  • 3
  • 12
0
votes
1 answer

Parsing CSV header into list of parsers

I want to parse first line of CSV file and to get list of parsers as a result, and fail miserably. After some simplifications I got code I think should work, but it does not, and I don't understand why. Here it is: {-# LANGUAGE OverloadedStrings…
0
votes
1 answer

Out of Memory Using Attoparsec

I'm trying to make a simple parser with attoparsec. The production rules are along the lines of: block: ?token> [inline] inline: foo | anyText So, what I'm trying to get at is, a block starts with the literal ?, followed by a token,…
nomen
  • 3,626
  • 2
  • 23
  • 40
0
votes
2 answers

Attoparsec compile errors

I am trying to learn to use attoparsec. I am trying to parse a text file of the following format: id int call_uuid string 30 My code is here: {-# LANGUAGE OverloadedStrings #-} import Control.Applicative ((<$>)) import Data.Char (isDigit,…
donatello
  • 5,727
  • 6
  • 32
  • 56
0
votes
2 answers

Trying to simplify the checking of an IO Bool in an Attoparsec parser

I'm trying to simplify the below code that's part of an attoparsec parser for a network packet, and I'm at a loss for a nice way to do it. It starts with a call to atEnd :: IO Bool to determine if there's more to parse. I can't find a nicer way to…
jhickner
  • 1,043
  • 10
  • 15
-2
votes
2 answers

how to parse yahoo historical csv with Attoparsec

i am a beginner of haskell, how to parse with attoparsec into open array, high array etc module CsvParser ( Quote (..) , csvFile , quote ) where import System.IO import Data.Attoparsec.Text import Data.Attoparsec.Combinator import…
Moyes
  • 3
  • 2
1 2 3
8
9