lambda_mountain 1.13.53

Compiler Backend / Programming Language Scaffolding
Documentation

macro ( ('let x y) )
      ( (λ x . ()) y );

macro ('match t ps) (scope(tail(
   (let (uuid term) (maybe-deref t))
   (match-pats( (uuid term) ps (fail 'PatternMatchFailure_s) ))
)));

macro ('match-pats( term () remainder )) (
   remainder
);

macro ('match-pats( term (ps (lhs rhs)) remainder )) (
   (match-pats( term ps
      (scope(if (match-pats-arm( term lhs )) rhs remainder))
   ))
);

macro ('match-pats-arm( term (:Variable: v) )) (
   (tail( (let v term) (branchtrue()) ))
);

macro ('match-pats-arm( term :Any: )) (
   (branchtrue())
);

macro ('match-pats-arm( term (:Literal: l) )) (
   (tail( (let (uuid v) term) (==( (uuid v) l )) ))
);

macro ('match-pats-arm( term (:Tag: l lt) )) (
   (tail( (let (uuid v) term) (==( (.0( (uuid v) )) l )) ))
);

macro ('match-pats-arm( term ((:Tag: l lt) ( x1 )) )) (
   (tail(
      (let (uuid v) term)
      (let (uuid m) 0_u8)
      (if (==( (.0( (uuid v) )) l ))
          (if (match-pats-arm( (maybe-deref(.1( (as (uuid v) lt) ))) x1 ))
              (set (uuid m) 1_u8)
              ()
          )
          ()
      )
      (==( (uuid m) 1_u8 ))
   ))
);

macro ('match-pats-arm( term ((:Tag: l lt) ( x2 x1 )) )) (
   (tail(
      (let (uuid v) term)
      (let (uuid m) 0_u8)
      (if (==( (.0( (uuid v) )) l ))
          (if (match-pats-arm( (maybe-deref(.1( (as (uuid v) lt) ))) x1 ))
              (if (match-pats-arm( (maybe-deref(.2( (as (uuid v) lt) ))) x2 ))
                  (set (uuid m) 1_u8)
                  ()
              )
              ()
          )
          ()
      )
      (==( (uuid m) 1_u8 ))
   ))
);

macro ('match-pats-arm( term ((:Tag: l lt) ( x3 x2 x1 )) )) (
   (tail(
      (let (uuid v) term)
      (let (uuid m) 0_u8)
      (if (==( (.0( (uuid v) )) l ))
          (if (match-pats-arm( (maybe-deref(.1( (as (uuid v) lt) ))) x1 ))
              (if (match-pats-arm( (maybe-deref(.2( (as (uuid v) lt) ))) x2 ))
                  (if (match-pats-arm( (maybe-deref(.3( (as (uuid v) lt) ))) x3 ))
                     (set (uuid m) 1_u8)
                     ()
                  )
                  ()
              )
              ()
          )
          ()
      )
      (==( (uuid m) 1_u8 ))
   ))
);

macro ('match-pats-arm( term ((:Tag: l lt) ( x4 x3 x2 x1 )) )) (
   (tail(
      (let (uuid v) term)
      (let (uuid m) 0_u8)
      (if (==( (.0( (uuid v) )) l ))
          (if (match-pats-arm( (maybe-deref(.1( (as (uuid v) lt) ))) x1 ))
              (if (match-pats-arm( (maybe-deref(.2( (as (uuid v) lt) ))) x2 ))
                  (if (match-pats-arm( (maybe-deref(.3( (as (uuid v) lt) ))) x3 ))
                     (if (match-pats-arm( (maybe-deref(.4( (as (uuid v) lt) ))) x4 ))
                        (set (uuid m) 1_u8)
                        ()
                     )
                     ()
                  )
                  ()
              )
              ()
          )
          ()
      )
      (==( (uuid m) 1_u8 ))
   ))
);

macro ('match-pats-arm( term ((:Tag: l lt) ( x5 x4 x3 x2 x1 )) )) (
   (tail(
      (let (uuid v) term)
      (let (uuid m) 0_u8)
      (if (==( (.0( (uuid v) )) l ))
          (if (match-pats-arm( (maybe-deref(.1( (as (uuid v) lt) ))) x1 ))
              (if (match-pats-arm( (maybe-deref(.2( (as (uuid v) lt) ))) x2 ))
                  (if (match-pats-arm( (maybe-deref(.3( (as (uuid v) lt) ))) x3 ))
                     (if (match-pats-arm( (maybe-deref(.4( (as (uuid v) lt) ))) x4 ))
                        (if (match-pats-arm( (maybe-deref(.5( (as (uuid v) lt) ))) x5 ))
                           (set (uuid m) 1_u8)
                           ()
                        )
                        ()
                     )
                     ()
                  )
                  ()
              )
              ()
          )
          ()
      )
      (==( (uuid m) 1_u8 ))
   ))
);