plsm-cpp/compiler/test.json
Ludwig Lehnert f8c17803c3 revamping...
2024-12-22 00:04:01 +01:00

142 lines
3.1 KiB
JSON

{
"@type": "Module",
"name": "default",
"imports": [],
"stmts": [
{
"@type": "FnDecl",
"name": "main",
"params": [],
"returnTypeName": {
"@type": "PrimitiveTypeName",
"name": "i64"
},
"body": [
{
"@type": "VarDecl",
"name": "asdf",
"typeName": {
"@type": "PrimitiveTypeName",
"name": "int"
}
},
{
"@type": "AssignStmt",
"lval": {
"@type": "Identifier",
"name": "asdf"
},
"rval": 100
},
{
"@type": "IfStmt",
"condition": {
"@type": "BinExpr",
"op": ">",
"lhs": {
"@type": "Identifier",
"name": "asdf"
},
"rhs": 1000
},
"ifBody": [
{
"@type": "AssignStmt",
"lval": {
"@type": "Identifier",
"name": "a"
},
"rval": 1
}
],
"elseBody": [
{
"@type": "IfStmt",
"condition": {
"@type": "BinExpr",
"op": ">",
"lhs": {
"@type": "Identifier",
"name": "asdf"
},
"rhs": 500
},
"ifBody": [
{
"@type": "AssignStmt",
"lval": {
"@type": "Identifier",
"name": "a"
},
"rval": 2
}
],
"elseBody": [
{
"@type": "AssignStmt",
"lval": {
"@type": "Identifier",
"name": "a"
},
"rval": 3
}
]
}
]
},
{
"@type": "WhileStmt",
"condition": {
"@type": "BinExpr",
"op": "<",
"lhs": {
"@type": "Identifier",
"name": "a"
},
"rhs": 10
},
"body": [
{
"@type": "AssignStmt",
"lval": {
"@type": "Identifier",
"name": "a"
},
"rval": {
"@type": "Identifier",
"name": "a"
}
},
{
"@type": "ExprStmt",
"expr": {
"@type": "UnExpr",
"op": "+",
"expr": 1
}
}
]
},
{
"@type": "RetStmt",
"value": {
"@type": "BinExpr",
"op": "+",
"lhs": {
"@type": "BinExpr",
"op": "*",
"lhs": 3,
"rhs": 10
},
"rhs": {
"@type": "BinExpr",
"op": "*",
"lhs": 21,
"rhs": 2
}
}
}
]
}
]
}