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
I have a grammar that has choices of elements, some of which have to be proceeded by the attempt parser (otherwise, I would get different grammar).
My problem is that a failing parser does not reflect the actual possibilities of the grammar.
To illustrate this behavior, check out this example:
let a = pchar 'a'
let bra = pchar '<'
let ket = pchar '>'
let comma = skipChar ','
let aBraKet = a .>> bra .>> ket
let aChoice = attempt aBraKet <|> a
// note that `let aChoice = aBraKet <|> a` would define a different grammar, in which we would never be able to parse a single `a`
// neither would `let aChoice = a <|> aBraKet` do the trick, because we would never be able to parse a single `a<>`.
let list = sepBy1 aChoice comma
let input = "a<>,a<>,a,axxx"
let result = run (list .>> eof) input
printf "%O" result
This will output
Failure:
Error in Ln: 1 Col: 12
a<>,a<>,a,axxx
^
Expecting: end of input or ','
The actual grammar, however, expects '<', ',' or end of input.
This behavior may be a feature and not a bug of FParsec, but would it be possible to enhance the error message to display every choice that is available in the grammar at this parsing state?
The text was updated successfully, but these errors were encountered:
I have a grammar that has choices of elements, some of which have to be proceeded by the
attempt
parser (otherwise, I would get different grammar).My problem is that a failing parser does not reflect the actual possibilities of the grammar.
To illustrate this behavior, check out this example:
This will output
The actual grammar, however, expects
'<', ',' or end of input
.This behavior may be a feature and not a bug of FParsec, but would it be possible to enhance the error message to display every choice that is available in the grammar at this parsing state?
The text was updated successfully, but these errors were encountered: