{ "kind" : "Program", "location" : [ 2, 1, 31, 1 ], "declarations" : [ { "kind" : "FuncDef", "location" : [ 2, 1, 11, 29 ], "name" : { "kind" : "Identifier", "location" : [ 2, 5, 2, 13 ], "name" : "get_prime" }, "params" : [ { "kind" : "TypedVar", "location" : [ 2, 15, 2, 19 ], "identifier" : { "kind" : "Identifier", "location" : [ 2, 15, 2, 15 ], "name" : "n" }, "type" : { "kind" : "ClassType", "location" : [ 2, 17, 2, 19 ], "className" : "int" } } ], "returnType" : { "kind" : "ClassType", "location" : [ 2, 25, 2, 27 ], "className" : "int" }, "declarations" : [ { "kind" : "VarDef", "location" : [ 3, 5, 3, 21 ], "var" : { "kind" : "TypedVar", "location" : [ 3, 5, 3, 17 ], "identifier" : { "kind" : "Identifier", "location" : [ 3, 5, 3, 13 ], "name" : "candidate" }, "type" : { "kind" : "ClassType", "location" : [ 3, 15, 3, 17 ], "className" : "int" } }, "value" : { "kind" : "IntegerLiteral", "location" : [ 3, 21, 3, 21 ], "value" : 2 } }, { "kind" : "VarDef", "location" : [ 4, 5, 4, 17 ], "var" : { "kind" : "TypedVar", "location" : [ 4, 5, 4, 13 ], "identifier" : { "kind" : "Identifier", "location" : [ 4, 5, 4, 9 ], "name" : "found" }, "type" : { "kind" : "ClassType", "location" : [ 4, 11, 4, 13 ], "className" : "int" } }, "value" : { "kind" : "IntegerLiteral", "location" : [ 4, 17, 4, 17 ], "value" : 0 } } ], "statements" : [ { "kind" : "WhileStmt", "location" : [ 5, 5, 11, 4 ], "condition" : { "kind" : "BooleanLiteral", "location" : [ 5, 11, 5, 14 ], "value" : true }, "body" : [ { "kind" : "IfStmt", "location" : [ 6, 9, 10, 8 ], "condition" : { "kind" : "CallExpr", "location" : [ 6, 12, 6, 30 ], "function" : { "kind" : "Identifier", "location" : [ 6, 12, 6, 19 ], "name" : "is_prime" }, "args" : [ { "kind" : "Identifier", "location" : [ 6, 21, 6, 29 ], "name" : "candidate" } ] }, "thenBody" : [ { "kind" : "AssignStmt", "location" : [ 7, 13, 7, 29 ], "targets" : [ { "kind" : "Identifier", "location" : [ 7, 13, 7, 17 ], "name" : "found" } ], "value" : { "kind" : "BinaryExpr", "location" : [ 7, 21, 7, 29 ], "left" : { "kind" : "Identifier", "location" : [ 7, 21, 7, 25 ], "name" : "found" }, "operator" : "+", "right" : { "kind" : "IntegerLiteral", "location" : [ 7, 29, 7, 29 ], "value" : 1 } } }, { "kind" : "IfStmt", "location" : [ 8, 13, 10, 8 ], "condition" : { "kind" : "BinaryExpr", "location" : [ 8, 16, 8, 25 ], "left" : { "kind" : "Identifier", "location" : [ 8, 16, 8, 20 ], "name" : "found" }, "operator" : "==", "right" : { "kind" : "Identifier", "location" : [ 8, 25, 8, 25 ], "name" : "n" } }, "thenBody" : [ { "kind" : "ReturnStmt", "location" : [ 9, 17, 9, 32 ], "value" : { "kind" : "Identifier", "location" : [ 9, 24, 9, 32 ], "name" : "candidate" } } ], "elseBody" : [ ] } ], "elseBody" : [ ] }, { "kind" : "AssignStmt", "location" : [ 10, 9, 10, 33 ], "targets" : [ { "kind" : "Identifier", "location" : [ 10, 9, 10, 17 ], "name" : "candidate" } ], "value" : { "kind" : "BinaryExpr", "location" : [ 10, 21, 10, 33 ], "left" : { "kind" : "Identifier", "location" : [ 10, 21, 10, 29 ], "name" : "candidate" }, "operator" : "+", "right" : { "kind" : "IntegerLiteral", "location" : [ 10, 33, 10, 33 ], "value" : 1 } } } ] }, { "kind" : "ReturnStmt", "location" : [ 11, 5, 11, 12 ], "value" : { "kind" : "IntegerLiteral", "location" : [ 11, 12, 11, 12 ], "value" : 0 } } ] }, { "kind" : "FuncDef", "location" : [ 13, 1, 19, 16 ], "name" : { "kind" : "Identifier", "location" : [ 13, 5, 13, 12 ], "name" : "is_prime" }, "params" : [ { "kind" : "TypedVar", "location" : [ 13, 14, 13, 18 ], "identifier" : { "kind" : "Identifier", "location" : [ 13, 14, 13, 14 ], "name" : "x" }, "type" : { "kind" : "ClassType", "location" : [ 13, 16, 13, 18 ], "className" : "int" } } ], "returnType" : { "kind" : "ClassType", "location" : [ 13, 24, 13, 27 ], "className" : "bool" }, "declarations" : [ { "kind" : "VarDef", "location" : [ 14, 5, 14, 15 ], "var" : { "kind" : "TypedVar", "location" : [ 14, 5, 14, 11 ], "identifier" : { "kind" : "Identifier", "location" : [ 14, 5, 14, 7 ], "name" : "div" }, "type" : { "kind" : "ClassType", "location" : [ 14, 9, 14, 11 ], "className" : "int" } }, "value" : { "kind" : "IntegerLiteral", "location" : [ 14, 15, 14, 15 ], "value" : 2 } } ], "statements" : [ { "kind" : "WhileStmt", "location" : [ 15, 5, 19, 4 ], "condition" : { "kind" : "BinaryExpr", "location" : [ 15, 11, 15, 17 ], "left" : { "kind" : "Identifier", "location" : [ 15, 11, 15, 13 ], "name" : "div" }, "operator" : "<", "right" : { "kind" : "Identifier", "location" : [ 15, 17, 15, 17 ], "name" : "x" } }, "body" : [ { "kind" : "IfStmt", "location" : [ 16, 9, 18, 8 ], "condition" : { "kind" : "BinaryExpr", "location" : [ 16, 12, 16, 23 ], "left" : { "kind" : "BinaryExpr", "location" : [ 16, 12, 16, 18 ], "left" : { "kind" : "Identifier", "location" : [ 16, 12, 16, 12 ], "name" : "x" }, "operator" : "%", "right" : { "kind" : "Identifier", "location" : [ 16, 16, 16, 18 ], "name" : "div" } }, "operator" : "==", "right" : { "kind" : "IntegerLiteral", "location" : [ 16, 23, 16, 23 ], "value" : 0 } }, "thenBody" : [ { "kind" : "ReturnStmt", "location" : [ 17, 13, 17, 24 ], "value" : { "kind" : "BooleanLiteral", "location" : [ 17, 20, 17, 24 ], "value" : false } } ], "elseBody" : [ ] }, { "kind" : "AssignStmt", "location" : [ 18, 9, 18, 21 ], "targets" : [ { "kind" : "Identifier", "location" : [ 18, 9, 18, 11 ], "name" : "div" } ], "value" : { "kind" : "BinaryExpr", "location" : [ 18, 15, 18, 21 ], "left" : { "kind" : "Identifier", "location" : [ 18, 15, 18, 17 ], "name" : "div" }, "operator" : "+", "right" : { "kind" : "IntegerLiteral", "location" : [ 18, 21, 18, 21 ], "value" : 1 } } } ] }, { "kind" : "ReturnStmt", "location" : [ 19, 5, 19, 15 ], "value" : { "kind" : "BooleanLiteral", "location" : [ 19, 12, 19, 15 ], "value" : true } } ] }, { "kind" : "VarDef", "location" : [ 22, 1, 22, 10 ], "var" : { "kind" : "TypedVar", "location" : [ 22, 1, 22, 5 ], "identifier" : { "kind" : "Identifier", "location" : [ 22, 1, 22, 1 ], "name" : "n" }, "type" : { "kind" : "ClassType", "location" : [ 22, 3, 22, 5 ], "className" : "int" } }, "value" : { "kind" : "IntegerLiteral", "location" : [ 22, 9, 22, 10 ], "value" : 15 } }, { "kind" : "VarDef", "location" : [ 25, 1, 25, 9 ], "var" : { "kind" : "TypedVar", "location" : [ 25, 1, 25, 5 ], "identifier" : { "kind" : "Identifier", "location" : [ 25, 1, 25, 1 ], "name" : "i" }, "type" : { "kind" : "ClassType", "location" : [ 25, 3, 25, 5 ], "className" : "int" } }, "value" : { "kind" : "IntegerLiteral", "location" : [ 25, 9, 25, 9 ], "value" : 1 } } ], "statements" : [ { "kind" : "WhileStmt", "location" : [ 28, 1, 31, 1 ], "condition" : { "kind" : "BinaryExpr", "location" : [ 28, 7, 28, 12 ], "left" : { "kind" : "Identifier", "location" : [ 28, 7, 28, 7 ], "name" : "i" }, "operator" : "<=", "right" : { "kind" : "Identifier", "location" : [ 28, 12, 28, 12 ], "name" : "n" } }, "body" : [ { "kind" : "ExprStmt", "location" : [ 29, 5, 29, 23 ], "expr" : { "kind" : "CallExpr", "location" : [ 29, 5, 29, 23 ], "function" : { "kind" : "Identifier", "location" : [ 29, 5, 29, 9 ], "name" : "print" }, "args" : [ { "kind" : "CallExpr", "location" : [ 29, 11, 29, 22 ], "function" : { "kind" : "Identifier", "location" : [ 29, 11, 29, 19 ], "name" : "get_prime" }, "args" : [ { "kind" : "Identifier", "location" : [ 29, 21, 29, 21 ], "name" : "i" } ] } ] } }, { "kind" : "AssignStmt", "location" : [ 30, 5, 30, 13 ], "targets" : [ { "kind" : "Identifier", "location" : [ 30, 5, 30, 5 ], "name" : "i" } ], "value" : { "kind" : "BinaryExpr", "location" : [ 30, 9, 30, 13 ], "left" : { "kind" : "Identifier", "location" : [ 30, 9, 30, 9 ], "name" : "i" }, "operator" : "+", "right" : { "kind" : "IntegerLiteral", "location" : [ 30, 13, 30, 13 ], "value" : 1 } } } ] } ], "errors" : { "errors" : [ ], "kind" : "Errors", "location" : [ 0, 0, 0, 0 ] } }