问题
I've got this code
type Exprs =
| Val of float
| Mult of Exprs * Exprs
| Plus of Exprs * Exprs
let pexpr, exprRef = createParserForwardedToRef<Exprs, unit>()
let pval = pfloat |>> Val
let binaryOp s = (ws >>. pexpr.>> ws) .>>. (ws >>. str s >>. ws >>. pexpr)
let pplus = binaryOp "+" |>> Plus
let pmuil = binaryOp "*" |>> Mult
do exprRef := choice [ attempt pmuil
pplus
pval ]
let expression = ws >>. pexpr .>> ws
When it evaluated it throws StackoverflowExcpetion. So the question is how can i write it without infinitie recursion?
来源:https://stackoverflow.com/questions/37077358/fparsec-recursive-grammatics-throw-stackoverflowexception