You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ChocoPy/pa3-tests/benchmarks/prime.py.ast.typed

658 lines
17 KiB

{
"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 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"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 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 0
}
} ],
"statements" : [ {
"kind" : "WhileStmt",
"location" : [ 5, 5, 11, 4 ],
"condition" : {
"kind" : "BooleanLiteral",
"location" : [ 5, 11, 5, 14 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "bool"
},
"value" : true
},
"body" : [ {
"kind" : "IfStmt",
"location" : [ 6, 9, 10, 8 ],
"condition" : {
"kind" : "CallExpr",
"location" : [ 6, 12, 6, 30 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "bool"
},
"function" : {
"kind" : "Identifier",
"location" : [ 6, 12, 6, 19 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "int"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "bool"
}
},
"name" : "is_prime"
},
"args" : [ {
"kind" : "Identifier",
"location" : [ 6, 21, 6, 29 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"name" : "candidate"
} ]
},
"thenBody" : [ {
"kind" : "AssignStmt",
"location" : [ 7, 13, 7, 29 ],
"targets" : [ {
"kind" : "Identifier",
"location" : [ 7, 13, 7, 17 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"name" : "found"
} ],
"value" : {
"kind" : "BinaryExpr",
"location" : [ 7, 21, 7, 29 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"left" : {
"kind" : "Identifier",
"location" : [ 7, 21, 7, 25 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"name" : "found"
},
"operator" : "+",
"right" : {
"kind" : "IntegerLiteral",
"location" : [ 7, 29, 7, 29 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 1
}
}
}, {
"kind" : "IfStmt",
"location" : [ 8, 13, 10, 8 ],
"condition" : {
"kind" : "BinaryExpr",
"location" : [ 8, 16, 8, 25 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "bool"
},
"left" : {
"kind" : "Identifier",
"location" : [ 8, 16, 8, 20 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"name" : "found"
},
"operator" : "==",
"right" : {
"kind" : "Identifier",
"location" : [ 8, 25, 8, 25 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"name" : "n"
}
},
"thenBody" : [ {
"kind" : "ReturnStmt",
"location" : [ 9, 17, 9, 32 ],
"value" : {
"kind" : "Identifier",
"location" : [ 9, 24, 9, 32 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"name" : "candidate"
}
} ],
"elseBody" : [ ]
} ],
"elseBody" : [ ]
}, {
"kind" : "AssignStmt",
"location" : [ 10, 9, 10, 33 ],
"targets" : [ {
"kind" : "Identifier",
"location" : [ 10, 9, 10, 17 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"name" : "candidate"
} ],
"value" : {
"kind" : "BinaryExpr",
"location" : [ 10, 21, 10, 33 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"left" : {
"kind" : "Identifier",
"location" : [ 10, 21, 10, 29 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"name" : "candidate"
},
"operator" : "+",
"right" : {
"kind" : "IntegerLiteral",
"location" : [ 10, 33, 10, 33 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 1
}
}
} ]
}, {
"kind" : "ReturnStmt",
"location" : [ 11, 5, 11, 12 ],
"value" : {
"kind" : "IntegerLiteral",
"location" : [ 11, 12, 11, 12 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"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 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 2
}
} ],
"statements" : [ {
"kind" : "WhileStmt",
"location" : [ 15, 5, 19, 4 ],
"condition" : {
"kind" : "BinaryExpr",
"location" : [ 15, 11, 15, 17 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "bool"
},
"left" : {
"kind" : "Identifier",
"location" : [ 15, 11, 15, 13 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"name" : "div"
},
"operator" : "<",
"right" : {
"kind" : "Identifier",
"location" : [ 15, 17, 15, 17 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"name" : "x"
}
},
"body" : [ {
"kind" : "IfStmt",
"location" : [ 16, 9, 18, 8 ],
"condition" : {
"kind" : "BinaryExpr",
"location" : [ 16, 12, 16, 23 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "bool"
},
"left" : {
"kind" : "BinaryExpr",
"location" : [ 16, 12, 16, 18 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"left" : {
"kind" : "Identifier",
"location" : [ 16, 12, 16, 12 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"name" : "x"
},
"operator" : "%",
"right" : {
"kind" : "Identifier",
"location" : [ 16, 16, 16, 18 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"name" : "div"
}
},
"operator" : "==",
"right" : {
"kind" : "IntegerLiteral",
"location" : [ 16, 23, 16, 23 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 0
}
},
"thenBody" : [ {
"kind" : "ReturnStmt",
"location" : [ 17, 13, 17, 24 ],
"value" : {
"kind" : "BooleanLiteral",
"location" : [ 17, 20, 17, 24 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "bool"
},
"value" : false
}
} ],
"elseBody" : [ ]
}, {
"kind" : "AssignStmt",
"location" : [ 18, 9, 18, 21 ],
"targets" : [ {
"kind" : "Identifier",
"location" : [ 18, 9, 18, 11 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"name" : "div"
} ],
"value" : {
"kind" : "BinaryExpr",
"location" : [ 18, 15, 18, 21 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"left" : {
"kind" : "Identifier",
"location" : [ 18, 15, 18, 17 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"name" : "div"
},
"operator" : "+",
"right" : {
"kind" : "IntegerLiteral",
"location" : [ 18, 21, 18, 21 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 1
}
}
} ]
}, {
"kind" : "ReturnStmt",
"location" : [ 19, 5, 19, 15 ],
"value" : {
"kind" : "BooleanLiteral",
"location" : [ 19, 12, 19, 15 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "bool"
},
"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 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"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 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 1
}
} ],
"statements" : [ {
"kind" : "WhileStmt",
"location" : [ 28, 1, 31, 1 ],
"condition" : {
"kind" : "BinaryExpr",
"location" : [ 28, 7, 28, 12 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "bool"
},
"left" : {
"kind" : "Identifier",
"location" : [ 28, 7, 28, 7 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"name" : "i"
},
"operator" : "<=",
"right" : {
"kind" : "Identifier",
"location" : [ 28, 12, 28, 12 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"name" : "n"
}
},
"body" : [ {
"kind" : "ExprStmt",
"location" : [ 29, 5, 29, 23 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 29, 5, 29, 23 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
},
"function" : {
"kind" : "Identifier",
"location" : [ 29, 5, 29, 9 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
},
"name" : "print"
},
"args" : [ {
"kind" : "CallExpr",
"location" : [ 29, 11, 29, 22 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"function" : {
"kind" : "Identifier",
"location" : [ 29, 11, 29, 19 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "int"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "get_prime"
},
"args" : [ {
"kind" : "Identifier",
"location" : [ 29, 21, 29, 21 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"name" : "i"
} ]
} ]
}
}, {
"kind" : "AssignStmt",
"location" : [ 30, 5, 30, 13 ],
"targets" : [ {
"kind" : "Identifier",
"location" : [ 30, 5, 30, 5 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"name" : "i"
} ],
"value" : {
"kind" : "BinaryExpr",
"location" : [ 30, 9, 30, 13 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"left" : {
"kind" : "Identifier",
"location" : [ 30, 9, 30, 9 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"name" : "i"
},
"operator" : "+",
"right" : {
"kind" : "IntegerLiteral",
"location" : [ 30, 13, 30, 13 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 1
}
}
} ]
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}