My languages use s-expressions with one additional function - a point operator for accessing elements from an array or structure.
Currently my parser works with this code using the access statement -
; Parition a sequence into a pair of sequences. ; NOTE: currently not tail-recursive. [defRec partition [pred seq] (if (isDone seq) (pair (list) (list)) (let (value (peek seq)) (nextSeq (next seq)) (nextResult (partition pred nextSeq)) (nextResultFirst (access :m:first nextResult)) (nextResultSecond (access :m:second nextResult)) (if (pred value) (pair (cons value nextResultFirst) nextResultSecond) (pair nextResultFirst (cons value nextResultSecond)))))]
However, I want to add alternative parsing using the so-called point operator -
; Parition a sequence into a pair of sequences. ; NOTE: currently not tail-recursive. [defRec partition [pred seq] (if (isDone seq) (pair (list) (list)) (let (value (peek seq)) (nextSeq (next seq)) (nextResult (partition pred nextSeq)) (nextResultFirst nextResult.first) (nextResultSecond nextResult.second) (if (pred value) (pair (cons value nextResultFirst) nextResultSecond) (pair nextResultFirst (cons value nextResultSecond)))))]
They will both disassemble the equivalent AST. Left recursion is present here because an expression of type (fx).y should be parsed just like (access :m:y (fx))
However, I don't know how to get FParsec to handle this type of left-recursive parsing or what alternatives I have left recursion on.
source share