You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello. I want to parse some ABFN like the following, to a string:
id = 3*(ALPHA / DIGIT)
name = "Z-" [id ":"] 1*(ALPHA / DIGIT / "-")
I'm trying with pipe commands because i cant find another way to concat all strings i match. Is this the right way to go or am i overlooking something? Following is a snippet of code:
open FParsec
open System
let test p str =
match run p str with
| Success(result, _, _) -> printfn "Success: %A" result
| Failure(errorMsg, _, _) -> printfn "Failure: %s" errorMsg
let id : Parser<string, unit> =
many1Chars (asciiLetter <|> digit)
let name : Parser<string, unit> =
pipe4 (pstring "Z-") id (pstring ":") (regex @"[A-Za-z0-9-]+") (fun s1 s2 s3 s4 ->
String.Concat [|s1; s2; s3; s4|])
test name "Z-ABC:MMSUBJ"
Thanks.
The text was updated successfully, but these errors were encountered:
Idrek
changed the title
Collect all parser results with pipe. Is this correct or is there any alternative?
Combine all parser results with pipe. Is this correct or is there any alternative?
Apr 19, 2022
Hello. I want to parse some ABFN like the following, to a string:
I'm trying with
pipe
commands because i cant find another way to concat all strings i match. Is this the right way to go or am i overlooking something? Following is a snippet of code:Thanks.
The text was updated successfully, but these errors were encountered: