tricu

An interpreted language for exploring Tree Calculus
Log | Files | Refs | README | LICENSE

stableRepeat.tri (531B)


      1 -- Direct self-recursion. The named parser returns the next input.
      2 -- Preserve the existing consumed/committed policy, without staging or thunks.
      3 repeat parser input reversed = (parserMatchReply
      4   (problem rest consumed committed : matchBool
      5     (err problem rest)
      6     (ok (reverse reversed) input)
      7     (or? consumed committed))
      8   (value rest consumed committed : matchBool
      9     (repeat parser rest (pair value reversed))
     10     (err "non-consuming parser" input)
     11     consumed)
     12   (parser input))
     13 main input = repeat parsePair input []