fparsec

FParsec failing on optional parser

蹲街弑〆低调 提交于 2021-02-07 21:12:32
问题 I am currently learning the FParsec library, but I have come across an issue. When I want to parse an optional string and continue parsing as normal afterwards, FParsec will return a fatal error on the optional parser, rather than returning None as I expect. The below working code sample illustrates my point: open System open FParsec type AccountEntity = | Default | Entity of string let pEntity = let isEntityFirstChar c = isLetter c let isEntityChar c = isLetter c || isDigit c (many1Satisfy2L

FParsec failing on optional parser

只愿长相守 提交于 2021-02-07 21:11:51
问题 I am currently learning the FParsec library, but I have come across an issue. When I want to parse an optional string and continue parsing as normal afterwards, FParsec will return a fatal error on the optional parser, rather than returning None as I expect. The below working code sample illustrates my point: open System open FParsec type AccountEntity = | Default | Entity of string let pEntity = let isEntityFirstChar c = isLetter c let isEntityChar c = isLetter c || isDigit c (many1Satisfy2L

FParsec failing on optional parser

穿精又带淫゛_ 提交于 2021-02-07 21:10:34
问题 I am currently learning the FParsec library, but I have come across an issue. When I want to parse an optional string and continue parsing as normal afterwards, FParsec will return a fatal error on the optional parser, rather than returning None as I expect. The below working code sample illustrates my point: open System open FParsec type AccountEntity = | Default | Entity of string let pEntity = let isEntityFirstChar c = isLetter c let isEntityChar c = isLetter c || isDigit c (many1Satisfy2L

Matching More than One ParserResult and Extracting Values

两盒软妹~` 提交于 2021-01-05 07:09:35
问题 This is a question about working with FParsec's ParserResult. Is there a cleaner implementation of match_result to pull out the XKEYVALUE or XATTRIBUTES contained inside the ParserResult without two nested matches? The following code works as a F# console app... // Learn more about F# at http://fsharp.org open System open FParsec // Types type XKEYVALUE = string * string type XATTRIBUTES = Map< string, string> type PARSER_RESULT_XML = | PR_XKEYVALUE of ParserResult<XKEYVALUE, unit> | PR

Matching More than One ParserResult and Extracting Values

岁酱吖の 提交于 2021-01-05 07:08:53
问题 This is a question about working with FParsec's ParserResult. Is there a cleaner implementation of match_result to pull out the XKEYVALUE or XATTRIBUTES contained inside the ParserResult without two nested matches? The following code works as a F# console app... // Learn more about F# at http://fsharp.org open System open FParsec // Types type XKEYVALUE = string * string type XATTRIBUTES = Map< string, string> type PARSER_RESULT_XML = | PR_XKEYVALUE of ParserResult<XKEYVALUE, unit> | PR

Is possible to parse “off-side” (indentation-based) languages with fparsec?

别说谁变了你拦得住时间么 提交于 2020-02-03 04:58:26
问题 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, how can feed it after lexing? P.D: I'm new at F#, but experienced in other languages 回答1: Yes, it's possible. Here is a relevant article by FParsec author. If you want to go deeper on the subject, this paper might worth a read. The paper points out that there are multiple packages for indentation

Is possible to parse “off-side” (indentation-based) languages with fparsec?

怎甘沉沦 提交于 2020-02-03 04:58:16
问题 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, how can feed it after lexing? P.D: I'm new at F#, but experienced in other languages 回答1: Yes, it's possible. Here is a relevant article by FParsec author. If you want to go deeper on the subject, this paper might worth a read. The paper points out that there are multiple packages for indentation

FParsec: how to parse date in fparsec (newbie)

▼魔方 西西 提交于 2020-01-14 19:06:48
问题 I am using the Bill Casarin post on how to parse delimited files with fparsec, I am dumbing the logic down to get an understanding of how the code works. I am parsing a multi row delimited document into Cell list list structure (for now) where a Cell is a string or a float. I am a complete newbie on this. I am having issues parsing the floats - in a typical case (a cell delimitted by tabs, containing a numeric) it works. However when a cell happens to be a string that starts with a number -

FParsec: how to parse date in fparsec (newbie)

旧时模样 提交于 2020-01-14 19:06:25
问题 I am using the Bill Casarin post on how to parse delimited files with fparsec, I am dumbing the logic down to get an understanding of how the code works. I am parsing a multi row delimited document into Cell list list structure (for now) where a Cell is a string or a float. I am a complete newbie on this. I am having issues parsing the floats - in a typical case (a cell delimitted by tabs, containing a numeric) it works. However when a cell happens to be a string that starts with a number -

Parsing method arguments with FParsec

北战南征 提交于 2020-01-13 13:04:06
问题 I am trying to implement a method arguments parser with FParsec. I was wondering if there is some already implemented feature in FParsec itself that'd aid me on this purpose? I ask this as FParsec provides tooling when dealing with operator precedence, so there might be something for this too. Parsing the opening and closing braces is pretty straight-forward. The headache lies in dealing with the following 3 cases that can happen: Method arguments can consist of: no arguments, one argument,