ssm-lang / sslang

A language built atop the Sparse Synchronous Model
BSD 3-Clause "New" or "Revised" License
18 stars 0 forks source link

Desugar topDef #128

Closed hzhou07 closed 1 year ago

hzhou07 commented 1 year ago

With this PR, the top level function definitions with pattern matching will be transformed into a equivalent one starting with a match in function body

  • Top level function definition with no pattern:
f  = expr

will remain unchanged

  • Top level function definition with one pattern:
f a = expr

will be desugered to:

f x = match x with
    a -> expr
  • Top level function definition with no less than two patterns:
f (x1,x2) (y1,y2) = expr

will be desugered to:

f v1 v2 = match (v1, v2) with
    ((x1,x2), (y1,y2))-> expr

Note: Should fail building until pull#116 is merged

j-hui commented 1 year ago

I'm going to close this, since it works on src/Front/Pattern/Desugar.hs, and that is now moved to the back-end. This desugaring should be done elsewhere.