evm2term
Version:
Translates from Egg Virtual Machine (JSON) to a summarized AST term
200 lines • 3.97 kB
JSON
{
"type": "apply",
"operator": {
"type": "word",
"line": 1,
"col": 1,
"length": 2,
"name": "do"
},
"args": [
{
"type": "apply",
"operator": {
"type": "word",
"line": 2,
"col": 5,
"length": 3,
"name": "def"
},
"args": [
{
"type": "word",
"line": 2,
"col": 9,
"length": 1,
"name": "b"
},
{
"type": "value",
"value": 4,
"line": 2,
"col": 11,
"length": 1
}
]
},
{
"type": "apply",
"operator": {
"type": "word",
"line": 3,
"col": 5,
"length": 3,
"name": "def"
},
"args": [
{
"type": "word",
"line": 3,
"col": 9,
"length": 5,
"name": "input"
},
{
"type": "value",
"value": "print(def(b,+(b,1)))",
"line": 3,
"col": 16,
"length": 22,
"raw": "\"print(def(b,+(b,1)))\""
}
]
},
{
"type": "apply",
"operator": {
"type": "word",
"line": 4,
"col": 5,
"length": 3,
"name": "def"
},
"args": [
{
"type": "word",
"line": 4,
"col": 9,
"length": 3,
"name": "ast"
},
{
"type": "apply",
"operator": {
"type": "word",
"line": 4,
"col": 14,
"length": 5,
"name": "parse"
},
"args": [
{
"type": "word",
"line": 4,
"col": 20,
"length": 5,
"name": "input"
}
]
}
]
},
{
"type": "apply",
"operator": {
"type": "word",
"line": 5,
"col": 5,
"length": 3,
"name": "def"
},
"args": [
{
"type": "word",
"line": 5,
"col": 9,
"length": 5,
"name": "scope"
},
{
"type": "property",
"operator": {
"type": "word",
"line": 5,
"col": 16,
"length": 15,
"name": "getCurrentScope"
},
"args": []
}
]
},
{
"type": "apply",
"operator": {
"type": "word",
"line": 6,
"col": 5,
"length": 4,
"name": "eval"
},
"args": [
{
"type": "apply",
"operator": {
"type": "word",
"line": 6,
"col": 11,
"length": 6,
"name": "object"
},
"args": [
{
"type": "value",
"value": "ast",
"line": 6,
"col": 11,
"length": 3,
"raw": "\"ast\""
},
{
"type": "word",
"line": 6,
"col": 16,
"length": 3,
"name": "ast"
},
{
"type": "value",
"value": "scope",
"line": 6,
"col": 21,
"length": 5,
"raw": "\"scope\""
},
{
"type": "property",
"operator": {
"type": "word",
"line": 6,
"col": 29,
"length": 5,
"name": "scope"
},
"args": [
{
"type": "value",
"value": "scope",
"line": 6,
"col": 35,
"length": 5,
"raw": "\"scope\""
}
]
}
]
}
]
}
]
}