I'm trying to replicate the structure of a simple if statement:
if (paren) { block } [else ({ block } | rec if (paren)) ]
for if (paren) block, I create a IfBlock AST node. Otherwise, it recursively fills a IfElseBlock node.
I've tried quite a few alternate constructions
let parse_if =
suffixparen .>>. suffixblock |>> IfBlock
//>>? attempt (str "else" >>. ifParser) |>> IfElseBlock
//<|> preturn IfBlock
// .>>? attempt (str "else" >>. ifParser) |>> IfElseBlock
// suffixparen .>>. suffixblock |>> IfBlock
// <|> ifParser |>> IfElseBlock
let inlineIf = str_ws "if" >>. parse_if
do ifParserR := inlineIf
Suggestions?