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
3
votes
1 answer

How to extract an FParsec result value to a variable in FSI

I'm using FParsec and trying to bind the resulting value to a variable in FSI. I tried with the following: > run pint32 "3";; // succeeds val it : ParserResult = Success: 3 > let x = run pint32 "3";; val…
beardc
  • 20,283
  • 17
  • 76
  • 94
3
votes
1 answer

Why does FParsec use lists?

I thought I'd try writing a fast parser using FParsec and quickly realised that many returning a list is a seriously performance problem. Then I discovered an alternative that uses a ResizeArray in the docs: let manyA2 p1 p = …
J D
  • 48,105
  • 13
  • 171
  • 274
3
votes
1 answer

How to parse a string value using FParsec

How do I parse a simple string out of another string. In the FParsec Tutorial there is the following code given: let str s = pstring s let floatBetweenBrackets = str "[" >>. pfloat .>> str "]" I don't want to parse a float between backets but more…
Peter Ittner
  • 551
  • 2
  • 13
3
votes
1 answer

Howto run FParsec in VS2013

How do I run FParsec in VS2013 Professional Edition? I tryed to use the following nuget packages: http://www.nuget.org/packages/FParsec/ http://www.nuget.org/packages/FParsec-Big-Data-Edition/ and I tried to compile the source-code of…
Peter Ittner
  • 551
  • 2
  • 13
3
votes
1 answer

Avoiding value restriction error for generic use of function that returns two functions

I want to use the FParsec createParserForwardedToRef function with a generic Expr union, like this: type Expr<'Term> =         | Unary of Operator * Expr<'Term>         | Binary of Operator * Expr<'Term> * Expr<'Term>         | Ternary of Operator *…
Rei Miyasaka
  • 7,007
  • 6
  • 42
  • 69
2
votes
1 answer

Parsing parenthesized expressions

I have the following fsyacc grammar for (a slightly modified form of) SQL search conditions: scalar_expr: | ID { Identifier($1) } | constant { Constant($1) } | unary_op…
Daniel
  • 47,404
  • 11
  • 101
  • 179
2
votes
3 answers

Differentiating logical from other infix operators

I'm trying to parse SQL search conditions and having trouble getting the parser to differentiate logical (AND, OR) from other infix operators. I'm parsing them as different nodes (perhaps that's difficult to do), but simplifies the evaluation phase.…
Daniel
  • 47,404
  • 11
  • 101
  • 179
2
votes
1 answer

Parsing string literals with FParsec?

I would like to parse string literals using FParsec. By "string literals" I mean something between opening and closing quote (in my case -- single quote): 'Please, switch off your mobile phone' What I am currently doing is the following: let string…
Alexander Galkin
  • 12,086
  • 12
  • 63
  • 115
2
votes
3 answers

Parsing into a complex type

I'm so new at F# and FParsec, I don't even want to embarrass myself by showing what I've got so far. In the FParsec examples, every type in the ASTs (that I see) are type abbreviations for single values, lists, or tuples. What if I have a complex…
Jason Kleban
  • 20,024
  • 18
  • 75
  • 125
2
votes
1 answer

Should I use Workflow or fsYacc?

I have a very simple DSL I need to parse on a .Net platform. Not being very experienced with parsers, I have been looking at examples using F# (fsLex, fsYacc, FParsec). I am not that familiar with F#, but do have some experience with Workflow and…
John
  • 511
  • 1
  • 5
  • 10
2
votes
1 answer

How to build FParsec for .NET Compact Framework?

I’m writing a small application based on FParsec. Today, I’m looking for an opportunity to make a version for Compact Framework. Apparently, it is not that simple to build FParsec sources for .NET CF. The FParsecCS library has unsafe code and some…
Be Brave Be Like Ukraine
  • 7,596
  • 3
  • 42
  • 66
2
votes
0 answers

How to parse CIMPLICITY's ctx file

I have to parse CIMPLICITY's ctx file. Ctx file sample: (Version 42) (DocumentSummary) (GmmiToplevelDocument (GmmiDocumentObject (GmmiContainerObject (GmmiObject "" 0 (Help "" "" "") (GmmiPointMap (GmmiPoint…
Y.Yanavichus
  • 2,387
  • 1
  • 21
  • 34
2
votes
1 answer

How to parse recusrive grammar in FParsec

Previous questions which I could not use to get this to work Recursive grammars in FParsec Seems to be an old question which was asked before createParserForwardedToRef was added to FParsec AST doesn't seem to be as horribly recursive as…
Chechy Levas
  • 2,206
  • 1
  • 13
  • 28
2
votes
3 answers

fparsec - limit number of characters that a parser is applied to

I have a problem where during the parsing of a stream I get to point where the next N characters need to be parsed by applying a specfic parser multiple times (in sequence). (stripped down toy) Example: 17
Friedrich Gretz
  • 535
  • 4
  • 14
2
votes
1 answer

Getting FParsec to reject unmatched start end tags?

Writing my own XML parser to learn FParsec I need to test that the XML start and end tags match or have the parser fail. In the code fragment below ... The parsers xStartTag and xKey return strings which I want to match. The parser…
rfreytag
  • 955
  • 1
  • 8
  • 24