fparsec Questions

2

Solved

I'm trying to parse a file, using FParsec, which consists of either float or int values. I'm facing two problems that I can't find a good solution for. 1 Both pint32 and pfloat will successfully...
Muscolo asked 3/2, 2016 at 10:11

2

Solved

Consider this parser that converts digit strings to ints: let toInt (s:string) = match Int32.TryParse(s) with | (true, n) -> preturn n | _ -> fail "Number must be below 2147483648" let ...
Bora asked 24/5, 2019 at 22:56

1

Solved

In order to create better error messages in a later step I want to save the positions on which a parser succeeds as well as the text. Getting the positions seems pretty easy (since there is the get...
Retouch asked 25/6, 2018 at 6:28

1

Solved

How can you detect when an FParsec parser has stopped without parsing all the input? For example, the following parser p stops when it finds the unexpected character d and does not continue to pa...
Gloxinia asked 27/5, 2018 at 14:34

1

Solved

I am trying to parse something that may be a list of items, or which may be just one item. I want to put the results into a DU (Thing below). The way I'm approaching this is as below, but it gives...
Debussy asked 21/5, 2018 at 19:37

3

Solved

Consider the following toy grammar and parser: (* in EBNF: ap = "a", { "ba" } bp = ap, "bc" *) let ap = sepBy1 (pstring "a") (pstring "b") let bp = ap .>> (pstring "bc") let test = run bp ...
Evaginate asked 12/8, 2017 at 19:5

1

Solved

I'm new to F# and have a pretty annoying problem. I want to parse the following grammar: Application := Expression Expression Expression := "(" "lambda" Name "." Application ")" | Name Name := [a...
Selvage asked 4/6, 2017 at 1:54

2

Solved

The example code below appears to work nicely: open FParsec let capitalized : Parser<unit,unit> =(asciiUpper >>. many asciiLower >>. eof) let inverted : Parser<unit,unit> =...
Hartill asked 15/11, 2016 at 20:57

3

Solved

I'm using FParsec to parse an input that describes its own format. For example, consider this input: int,str,int:4,'hello',3 The first part of the input (before the colon) describes the format o...
Virginavirginal asked 19/4, 2015 at 7:36

1

I'm trying to write a parser for the Mathematica language in F# using FParsec. I have written one for a MiniML that supports the syntax f x y = (f(x))(y) with high precedence for function applicat...
Poleaxe asked 28/3, 2015 at 21:34

1

Solved

I wish to use FParsec for a python-like language, indentation-based. I understand that this must be done in the lexing phase, but FParsec don't have a lexing phase. Is possible to use FParsec, or,...
Indulge asked 27/11, 2014 at 2:47

1

Solved

I plan to use FParsec for the prototype of a larger project of mine. So I decided to get my first experiences with this library by means of the test program listed below. But it seems that the comb...
Lapidate asked 25/5, 2014 at 23:52

1

Solved

I'm trying to parse some information out of largely free-form text. I attempted an implementation in FParsec, but I haven't used it before and I'm not sure if I'm doing it wrong, or even if it is w...
Psychophysics asked 20/2, 2014 at 23:20

1

Solved

I have this test program: open FParsec let test p str = match run p str with | Success(result, _, _) -> printfn "Success: %A" result | Failure(errorMsg, _, _) -> printfn "Failure: %s" er...
Aurochs asked 19/5, 2013 at 19:58

2

Solved

I am looking for some sample grammars written in FParsec that would go beyond the samples in the project repository. I have found this very nice grammar of GLSL, but this is the only sample I foun...
Italy asked 30/1, 2012 at 9:39

2

Solved

As a follow-on to: How do I test for exactly 2 characters with fparsec? I need to parse a string that consists of pairs of identifiers followed by freeform text. I can easily construct a parser th...
Maomaoism asked 14/5, 2013 at 3:33

1

Solved

I have the following program that runs. It takes a line of text and splits it into two parts, the first is an identifier and the second is the remainder of the line. My parser for the identifier (f...
Metagalaxy asked 13/5, 2013 at 15:39

3

Solved

I have the following subexpression to parse 'quotes' which have the following format "5.75 @ 5.95" I therefore have this parsec expression to parse it let pquote x = (sepBy (pfloat) ((spaces ....
Build asked 4/5, 2012 at 15:56

1

Solved

Assume I've this parser: let test p str = match run p str with | Success(result, _, _) -> printfn "Success: %A" result | Failure(errorMsg, _, _) -> printfn "Failure: %s" errorMsg let myS...
Waterrepellent asked 12/2, 2012 at 11:29

1

Solved

The question is similar to this one, but I want to parse an expression with function application using the OperatorPrecedenceParser in FParsec. Here is my AST: type Expression = | Float of float...
Erbe asked 8/2, 2012 at 16:45

1

Solved

I've started learning FParsec. It has a very flexible way to parse numbers; I can provide a set of number formats I want to use: type Number = | Numeral of int | Decimal of float | Hexadecimal ...
Ihab asked 6/2, 2012 at 11:41

1

Solved

Is it possible to submit input to an FParsec parser in chunks, as from a socket? If not, is it possible to retrieve the current result and unparsed portion of an input stream so that I might accomp...
Brail asked 17/1, 2012 at 7:27

1

Solved

I'm attempting to parse lisp-style comments from an s-expression language with FParsec. I got a bit of help with parsing single-line comments in this previous thread - How to convert an FParsec par...
Abram asked 6/12, 2011 at 18:41

1

Solved

I'm implementing a parser that treats comments as white space with FParsec. It seems like it requires a trivial parser conversion, but I don't yet know how to implement that. Here's the code I'm t...
Corral asked 6/12, 2011 at 3:53

2

Solved

I am familiar with some of the basics of fparsec but it seems to be geared towards text files or streams. Are there any other F# library's that can efficiently parse binary files? Or can fparsec b...
Raviv asked 17/10, 2011 at 22:57

© 2022 - 2024 — McMap. All rights reserved.