tricu

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

to-source.scp (611B)


      1 -- Render the *tree*, not an AST or a remembered source spelling.
      2 -- State: join worker with an append worker in its initial state. It is
      3 -- deliberately verbose: SCP has no string-concatenation output form.
      4 consumer toSource
      5   leaf          @ _      => "t"
      6   stem child    @ joiner => call joiner ("(t ", recur child @ joiner) as start in
      7     call joiner (start, ")") as text in text
      8   (left, right) @ joiner => call joiner ("(t ", recur left  @ joiner) as start in
      9     call joiner (start, " ") as spaced in
     10     call joiner (spaced, recur right @ joiner) as body in
     11     call joiner (body, ")") as text in text