Questions tagged [fparsec]

A parser combinator library for F#.

FParsec is a parser combinator library for F#.

FParsec’s features include:

  • support for context‐sensitive, infinite look‐ahead grammars,
  • automatically generated, highly readable error messages,
  • Unicode support,
  • efficient support for very large files,
  • an embeddable, runtime‐configurable operator‐precedence parser component,
  • a simple, efficient and easily extensible API,
  • an implementation thoroughly optimized for performance,
  • comprehensive documentation,
  • a permissive open source license.

FParsec is an F# adaptation of Parsec, the popular parser combinator library for Haskell.

FParsec is optimized for an applicative programming style, but it also supports a monadic syntax similar to Parsec's.

See http://www.quanttec.com/fparsec/ for more information.

191 questions
1
vote
1 answer

fparsec rfc2822 parsing multiple header lines

I'm trying to parse RFC 2822 using fparsec but I'm unable to deal with the headers with multiple lines: (it gets confused with the next header): here's my best try: do you have any tips? let str (s:string) = pstring s let stringLiteral = …
Koenig Lear
  • 2,366
  • 1
  • 14
  • 29
1
vote
1 answer

FParsec and a delimiter based syntax

I'm trying to use fparsec to parse a simple todo list language (the data from TaskPaper actually) as a simple parser combinator example. But I've run into a bug I can't seem to puzzle out. I'm new to parser combinators and FParsec seems to rely on…
Ball
  • 2,591
  • 3
  • 19
  • 26
1
vote
1 answer

Why doesn't the FParsec example run?

So I'm running the following code from the FParsec sample, but it doesn't seem to want to run. namespace Test open FParsec.CharParsers module Stuff = let main = run pfloat "1.25E3" let str s = pstring s let floatBetweenBrackets = str "[" >>.…
Carbon
  • 3,828
  • 3
  • 24
  • 51
1
vote
1 answer

How to parse prefix function such as Pow() with multiple parameters using FParsec

I tried to parse a prefix function such as Pow(3+2,2) using FParsec. I read the calculator tutorial in the example files as follows. The examples are all unary prefix function. I wonder how can I achieve prefix functions with more than one inputs…
zyzhu
  • 266
  • 2
  • 7
1
vote
0 answers

Fparsec recursive grammatics throw StackOverflowException

I've got this code type Exprs = | Val of float | Mult of Exprs * Exprs | Plus of Exprs * Exprs let pexpr, exprRef = createParserForwardedToRef() let pval = pfloat |>> Val let binaryOp s = (ws >>. pexpr.>> ws) .>>. (ws…
neftedollar
  • 1,108
  • 10
  • 14
1
vote
1 answer

Use FParsec on already tokenized UInt16 stream

I need to parse an already tokenized stream of type UInt16 seq. How can I do this with FParsec? All the top level functions I can find in the reference work on charstreams. At the moment I convert the UInt16s to chars which seems silly.
3dGrabber
  • 4,710
  • 1
  • 34
  • 42
1
vote
1 answer

error in BNF fparsec parser

I have made the following parser to try to parse BNF: type Literal = Literal of string type RuleName = RuleName of string type Term = Literal of Literal | RuleName of RuleName type List = List of Term list type Expression = Expression of…
gbieging
  • 320
  • 1
  • 13
1
vote
1 answer

Compatibility .Net 4.0 and .Net 4.5. Could not load file or Assembly 'FSharp.Core, Version=4.3.1.0.'

I want to use the library Math.NET Symbolics in the F# project. But when I run simple code: open MathNet.Symbolics open MathNet.Symbolics.Operators ... let expr = Infix.parseOrThrow("sin(x) * y") let symbols = Map.ofList [ "x", Real 2.0; "y", Real…
FoggyFinder
  • 2,230
  • 2
  • 20
  • 34
1
vote
0 answers

How use FParsec for indentation-based statements (like in python)?

So, I have a basic parser for my language, and according to Is possible to parse "off-side" (indentation-based) languages with fparsec? I want to incorporate indentation-based syntax for it, like in python. However, I'm struggling to see how…
mamcx
  • 15,916
  • 26
  • 101
  • 189
1
vote
2 answers

F#, FParsec, and Calling a Stream Parser Recursively, Second Take

Thank you for the replies to my first post and my second post on this project. This question is basically the same question as the first, but with my code updated according to the feedback received on those two questions. How do I call my parser…
Jeff Maner
  • 1,179
  • 9
  • 23
1
vote
1 answer

F#, FParsec, and Calling a Stream Parser Recursively

I'm developing a multi-part MIME parser using F# and FParsec. I'm developing iteratively, and so this is highly unrefined, brittle code--it only solves my first immediate problem. Red, Green, Refactor. I'm required to parse a stream rather than a…
Jeff Maner
  • 1,179
  • 9
  • 23
1
vote
1 answer

How to use FParsec to parse into a record or object?

After completing the FParsec tutorial, I decided to try writing a parser for SDP (Session Description Protocol RFC 4366) - at least the first 3 lines. SDP is specified in ABNF (RFC 4234)); so, I’m trying to work from that. The note at the end of…
Ron Woods
  • 122
  • 1
  • 7
1
vote
1 answer

fparsec key-value parser fails to parse

I have to write a parser which parses key-value pairs in a file that looks like this: as235 242kj25klj Pairs:A=a1|B=b1|C=c1 kjlkjlkjlkj Pairs:A=a2|B=b2|C=c2 Note that the lines contain some garbage, the label and then the key-value pairs. The F#…
vidi
  • 2,056
  • 16
  • 34
1
vote
1 answer

Fparsec vs regular expressions

What is the advantage of using a library like FParsec for parsing text over using plain regular expressions from a .NET language?
1
vote
1 answer

'sepEndBy' does not capture if wrapped in in 'between'

I want to parse the following text: WHERE ( AND ApplicationGroup.REFSTR = 5 BV_1.Year = 2009 BV_1.MonetaryCodeId = 'Commited' BV_3.Year = 2009 BV_3.MonetaryCodeId = 'Commited' BV_4.Year = 2009 …
Joachim Rosskopf
  • 1,259
  • 2
  • 13
  • 24