evm2term
Version:
Translates from Egg Virtual Machine (JSON) to a summarized AST term
262 lines • 4.96 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": 2,
"name": "do"
},
"args": []
}
]
},
{
"type": "apply",
"operator": {
"type": "word",
"line": 6,
"col": 5,
"length": 1,
"name": "="
},
"args": [
{
"type": "property",
"operator": {
"type": "word",
"line": 6,
"col": 7,
"length": 5,
"name": "scope"
},
"args": [
{
"type": "value",
"value": "ast",
"line": 6,
"col": 13,
"length": 3,
"raw": "\"ast\""
}
]
},
{
"type": "word",
"line": 6,
"col": 18,
"length": 3,
"name": "ast"
}
]
},
{
"type": "apply",
"operator": {
"type": "word",
"line": 7,
"col": 5,
"length": 1,
"name": "="
},
"args": [
{
"type": "property",
"operator": {
"type": "property",
"operator": {
"type": "word",
"line": 7,
"col": 7,
"length": 5,
"name": "scope"
},
"args": [
{
"type": "value",
"value": "scope",
"line": 7,
"col": 13,
"length": 5,
"raw": "\"scope\""
}
]
},
"args": [
{
"type": "value",
"value": "b",
"line": 7,
"col": 19,
"length": 3,
"raw": "\"b\""
}
]
},
{
"type": "value",
"value": 10,
"line": 7,
"col": 25,
"length": 2
}
]
},
{
"type": "apply",
"operator": {
"type": "word",
"line": 8,
"col": 5,
"length": 5,
"name": "print"
},
"args": [
{
"type": "word",
"line": 8,
"col": 11,
"length": 3,
"name": "ast"
}
]
},
{
"type": "apply",
"operator": {
"type": "word",
"line": 9,
"col": 5,
"length": 4,
"name": "eval"
},
"args": [
{
"type": "word",
"line": 9,
"col": 10,
"length": 5,
"name": "scope"
}
]
}
]
}