githwxi / ATS-Xanadu

Bootstrapping ATS3
GNU General Public License v3.0
196 stars 14 forks source link

Jsonize #20

Closed sparverius closed 4 years ago

sparverius commented 4 years ago

Jsonize proof of concept. Still needs plenty of work though curious to hear your thoughts before proceeding.

An example of output from quick test:

{"node": "ir0exp", "val": {"node": "IR0Edapp", "val": [{"node": "ir0exp", "val": "IR0Evar"}, -1, [{"node": "ir0exp", "val": "IR0Evar"}, {"node": "ir0exp", "val": "IR0Evar"}]]}}

Same example formatted:

{
  "node": "ir0exp",
  "val": {
    "node": "IR0Edapp",
    "val": [
      {
        "node": "ir0exp",
        "val": "IR0Evar"
      },
      -1,
      [
        {
          "node": "ir0exp",
          "val": "IR0Evar"
        },
        {
          "node": "ir0exp",
          "val": "IR0Evar"
        }
      ]
    ]
  }
}

or, perhaps more like this:

{"IR0Edapp": {"irf0": {"IR0Econ1": {"d2c": {"d2con": {"symbol": "list_cons", "stamp": "7"}}}}, "npf1": -1, "ires": [{"IR0Edapp": {"irf0": {"IR0Evar": {"d2v": {"d2var": {"symbol": "f0", "stamp": "2"}}}}, "npf1": -1, "ires": [{"IR0Evar": {"d2v": {"d2var": {"symbol": "x0", "stamp": "3"}}}}]}}, {"IR0Edapp": {"irf0": {"IR0Evar": {"d2v": {"d2var": {"symbol": "map", "stamp": "0"}}}}, "npf1": -1, "ires": [{"IR0Evar": {"d2v": {"d2var": {"symbol": "xs", "stamp": "4"}}}}, {"IR0Evar": {"d2v": {"d2var": {"symbol": "f0", "stamp": "2"}}}}]}}]}}
{
  "IR0Edapp": {
    "irf0": {
      "IR0Econ1": {
        "d2c": {
          "d2con": {
            "symbol": "list_cons",
            "stamp": "7"
          }
        }
      }
    },
    "npf1": -1,
    "ires": [
      {
        "IR0Edapp": {
          "irf0": {
            "IR0Evar": {
              "d2v": {
                "d2var": {
                  "symbol": "f0",
                  "stamp": "2"
                }
              }
            }
          },
          "npf1": -1,
          "ires": [
            {
              "IR0Evar": {
                "d2v": {
                  "d2var": {
                    "symbol": "x0",
                    "stamp": "3"
                  }
                }
              }
            }
          ]
        }
      },
      {
        "IR0Edapp": {
          "irf0": {
            "IR0Evar": {
              "d2v": {
                "d2var": {
                  "symbol": "map",
                  "stamp": "0"
                }
              }
            }
          },
          "npf1": -1,
          "ires": [
            {
              "IR0Evar": {
                "d2v": {
                  "d2var": {
                    "symbol": "xs",
                    "stamp": "4"
                  }
                }
              }
            },
            {
              "IR0Evar": {
                "d2v": {
                  "d2var": {
                    "symbol": "f0",
                    "stamp": "2"
                  }
                }
              }
            }
          ]
        }
      }
    ]
  }
}