tricu

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

b132ca49c22098c8a5d638517d701ad8141028d9389594ac2134240d240a2637.tri (1962B)


      1 !import prelude *
      2 !export *
      3 
      4 -- Resolved gate-profile core AST. Every node retains a half-open source span.
      5 -- node = pair kind (pair payload (pair start end))
      6 sourceCoreNode kind payload start end =
      7   pair kind (pair payload (pair start end))
      8 sourceCoreKind node = fst node
      9 sourceCorePayload node = fst (snd node)
     10 sourceCoreStart node = fst (snd (snd node))
     11 sourceCoreEnd node = snd (snd (snd node))
     12 
     13 sourceCoreLeafKind = 1
     14 sourceCoreBoundKind = 2
     15 sourceCoreApplyKind = 3
     16 sourceCoreLambdaKind = 4
     17 sourceCoreExternalKind = 5
     18 sourceCoreNumberKind = 6
     19 sourceCoreStringKind = 7
     20 sourceCoreListKind = 8
     21 
     22 sourceCoreLeaf start end = sourceCoreNode sourceCoreLeafKind t start end
     23 sourceCoreBound index start end =
     24   sourceCoreNode sourceCoreBoundKind index start end
     25 sourceCoreApply left right start end =
     26   sourceCoreNode sourceCoreApplyKind (pair left right) start end
     27 sourceCoreLambda body start end =
     28   sourceCoreNode sourceCoreLambdaKind body start end
     29 sourceCoreExternal tree start end =
     30   sourceCoreNode sourceCoreExternalKind tree start end
     31 sourceCoreNumber value start end =
     32   sourceCoreNode sourceCoreNumberKind value start end
     33 sourceCoreString value start end =
     34   sourceCoreNode sourceCoreStringKind value start end
     35 sourceCoreList elements start end =
     36   sourceCoreNode sourceCoreListKind elements start end
     37 
     38 sourceCoreWithSpan node start end =
     39   sourceCoreNode (sourceCoreKind node) (sourceCorePayload node) start end
     40 
     41 
     42 -- Shared delayed native fixed point, self-first: fix f x = f (fix f) x.
     43 -- Kept below both resolution and stable compilation to avoid a module cycle.
     44 -- Closed compiler trees, not lookups of caller-provided y/fix identifiers.
     45 sourceCoreFixI = t (t (t t)) t
     46 sourceCoreFixSelf = t (t sourceCoreFixI) sourceCoreFixI
     47 sourceCoreFixWait f x = t (t (t (t (t t f)) (t t x))) sourceCoreFixI
     48 sourceCoreFixWaitSelf x = sourceCoreFixWait sourceCoreFixSelf x
     49 sourceCoreFix f = sourceCoreFixWait sourceCoreFixSelf (t (t (t t f)) sourceCoreFixWaitSelf)