Protean-Labs / mesh

The Mesh Engine that implements the Mesh Language, a computational language for web3.
Apache License 2.0
1 stars 0 forks source link

Feature/records #64

Closed ThierryBleau closed 3 years ago

ThierryBleau commented 3 years ago

Implements extensible records and refactors type variable tracking.

cvauclair commented 3 years ago

@ThierryBleau

I added parsing support for records but made two assumptions in the process:

  1. Given the AST node ERecExtend(name, e1, e2), I assumed that e1 is the value of the new field and e2 is the record being extended. E.g.: {...x, a: 1} is parsed as ERecExtend("a", ELit(Int(2)), EVar([], "x")).
  2. Record expressions with multiple fields are represented as nested ERecExtend AST nodes with the inner most ERecExtend being the first field of the record. E.g.: {a:1, b:2, c:3} is parsed as
    (ERecExtend c
    (ELit 3)
    (ERecExtend b
    (ELit 2)
    (ERecExtend a
      (ELit 1)
      ERecEmpty)))

Please validate (or invalidate) these assumptions