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...
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...
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...
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...
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...
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> =...
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...
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...
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...
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...
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...
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...
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...
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...
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 ....
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...
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...
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 ...
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...
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...
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...
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
1 Next >
© 2022 - 2024 — McMap. All rights reserved.