while loops work!
This commit is contained in:
120
debug/ast.json
120
debug/ast.json
@@ -1,48 +1,6 @@
|
||||
{
|
||||
"type": "Program",
|
||||
"statements": [
|
||||
{
|
||||
"FunctionStatement": {
|
||||
"type": "FunctionStatement",
|
||||
"name": {
|
||||
"type": "IdentifierLiteral",
|
||||
"value": "add"
|
||||
},
|
||||
"return_type": "Int",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "FunctionParameter",
|
||||
"name": "a",
|
||||
"value_type": "Int"
|
||||
},
|
||||
{
|
||||
"type": "FunctionParameter",
|
||||
"name": "b",
|
||||
"value_type": "Int"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"statements": [
|
||||
{
|
||||
"type": "ReturnStatement",
|
||||
"return_value": {
|
||||
"type": "InfixExpression",
|
||||
"left_node": {
|
||||
"type": "IdentifierLiteral",
|
||||
"value": "a"
|
||||
},
|
||||
"operator": "+",
|
||||
"right_node": {
|
||||
"type": "IdentifierLiteral",
|
||||
"value": "b"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"FunctionStatement": {
|
||||
"type": "FunctionStatement",
|
||||
@@ -56,34 +14,72 @@
|
||||
"type": "BlockStatement",
|
||||
"statements": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"expr": {
|
||||
"type": "CallExpression",
|
||||
"function": {
|
||||
"type": "AssignmentStatement",
|
||||
"name": {
|
||||
"type": "IdentifierLiteral",
|
||||
"value": "a"
|
||||
},
|
||||
"value": {
|
||||
"type": "IntegerLiteral",
|
||||
"value": 0
|
||||
},
|
||||
"value_type": "Int"
|
||||
},
|
||||
{
|
||||
"type": "WhileStatement",
|
||||
"condition": {
|
||||
"type": "InfixExpression",
|
||||
"left_node": {
|
||||
"type": "IdentifierLiteral",
|
||||
"value": "print"
|
||||
"value": "a"
|
||||
},
|
||||
"arguments": [
|
||||
"operator": "<",
|
||||
"right_node": {
|
||||
"type": "IntegerLiteral",
|
||||
"value": 10
|
||||
}
|
||||
},
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"statements": [
|
||||
{
|
||||
"type": "StringLiteral",
|
||||
"value": "apples %i"
|
||||
"type": "ExpressionStatement",
|
||||
"expr": {
|
||||
"type": "CallExpression",
|
||||
"function": {
|
||||
"type": "IdentifierLiteral",
|
||||
"value": "print"
|
||||
},
|
||||
"arguments": [
|
||||
{
|
||||
"type": "StringLiteral",
|
||||
"value": "a = %i\\n"
|
||||
},
|
||||
{
|
||||
"type": "IdentifierLiteral",
|
||||
"value": "a"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "CallExpression",
|
||||
"function": {
|
||||
"type": "ReassignStatement",
|
||||
"ident": {
|
||||
"type": "IdentifierLiteral",
|
||||
"value": "add"
|
||||
"value": "a"
|
||||
},
|
||||
"arguments": [
|
||||
{
|
||||
"right_value": {
|
||||
"type": "InfixExpression",
|
||||
"left_node": {
|
||||
"type": "IdentifierLiteral",
|
||||
"value": "a"
|
||||
},
|
||||
"operator": "+",
|
||||
"right_node": {
|
||||
"type": "IntegerLiteral",
|
||||
"value": 1
|
||||
},
|
||||
{
|
||||
"type": "IntegerLiteral",
|
||||
"value": 2
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -91,8 +87,8 @@
|
||||
{
|
||||
"type": "ReturnStatement",
|
||||
"return_value": {
|
||||
"type": "IntegerLiteral",
|
||||
"value": 0
|
||||
"type": "IdentifierLiteral",
|
||||
"value": "a"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user