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/pa2-tests/extra/exp.py.ast

375 lines
9.4 KiB

4 years ago
{
"kind" : "Program",
"location" : [ 2, 1, 26, 1 ],
"declarations" : [ {
"kind" : "FuncDef",
"location" : [ 2, 1, 14, 13 ],
"name" : {
"kind" : "Identifier",
"location" : [ 2, 5, 2, 7 ],
"name" : "exp"
},
"params" : [ {
"kind" : "TypedVar",
"location" : [ 2, 9, 2, 14 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 2, 9, 2, 9 ],
"name" : "x"
},
"type" : {
"kind" : "ClassType",
"location" : [ 2, 12, 2, 14 ],
"className" : "int"
}
}, {
"kind" : "TypedVar",
"location" : [ 2, 17, 2, 22 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 2, 17, 2, 17 ],
"name" : "y"
},
"type" : {
"kind" : "ClassType",
"location" : [ 2, 20, 2, 22 ],
"className" : "int"
}
} ],
"returnType" : {
"kind" : "ClassType",
"location" : [ 2, 28, 2, 30 ],
"className" : "int"
},
"declarations" : [ {
"kind" : "VarDef",
"location" : [ 3, 2, 3, 11 ],
"var" : {
"kind" : "TypedVar",
"location" : [ 3, 2, 3, 7 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 3, 2, 3, 2 ],
"name" : "a"
},
"type" : {
"kind" : "ClassType",
"location" : [ 3, 5, 3, 7 ],
"className" : "int"
}
},
"value" : {
"kind" : "IntegerLiteral",
"location" : [ 3, 11, 3, 11 ],
"value" : 0
}
}, {
"kind" : "FuncDef",
"location" : [ 4, 2, 13, 1 ],
"name" : {
"kind" : "Identifier",
"location" : [ 4, 6, 4, 6 ],
"name" : "f"
},
"params" : [ {
"kind" : "TypedVar",
"location" : [ 4, 8, 4, 13 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 4, 8, 4, 8 ],
"name" : "i"
},
"type" : {
"kind" : "ClassType",
"location" : [ 4, 11, 4, 13 ],
"className" : "int"
}
} ],
"returnType" : {
"kind" : "ClassType",
"location" : [ 4, 19, 4, 21 ],
"className" : "int"
},
"declarations" : [ {
"kind" : "NonLocalDecl",
"location" : [ 5, 3, 5, 12 ],
"variable" : {
"kind" : "Identifier",
"location" : [ 5, 12, 5, 12 ],
"name" : "a"
}
}, {
"kind" : "FuncDef",
"location" : [ 6, 3, 7, 12 ],
"name" : {
"kind" : "Identifier",
"location" : [ 6, 7, 6, 10 ],
"name" : "geta"
},
"params" : [ ],
"returnType" : {
"kind" : "ClassType",
"location" : [ 6, 17, 6, 19 ],
"className" : "int"
},
"declarations" : [ ],
"statements" : [ {
"kind" : "ReturnStmt",
"location" : [ 7, 4, 7, 11 ],
"value" : {
"kind" : "Identifier",
"location" : [ 7, 11, 7, 11 ],
"name" : "a"
}
} ]
} ],
"statements" : [ {
"kind" : "IfStmt",
"location" : [ 8, 3, 13, 1 ],
"condition" : {
"kind" : "BinaryExpr",
"location" : [ 8, 6, 8, 11 ],
"left" : {
"kind" : "Identifier",
"location" : [ 8, 6, 8, 6 ],
"name" : "i"
},
"operator" : "<=",
"right" : {
"kind" : "IntegerLiteral",
"location" : [ 8, 11, 8, 11 ],
"value" : 0
}
},
"thenBody" : [ {
"kind" : "ReturnStmt",
"location" : [ 9, 4, 9, 16 ],
"value" : {
"kind" : "CallExpr",
"location" : [ 9, 11, 9, 16 ],
"function" : {
"kind" : "Identifier",
"location" : [ 9, 11, 9, 14 ],
"name" : "geta"
},
"args" : [ ]
}
} ],
"elseBody" : [ {
"kind" : "AssignStmt",
"location" : [ 11, 4, 11, 12 ],
"targets" : [ {
"kind" : "Identifier",
"location" : [ 11, 4, 11, 4 ],
"name" : "a"
} ],
"value" : {
"kind" : "BinaryExpr",
"location" : [ 11, 8, 11, 12 ],
"left" : {
"kind" : "Identifier",
"location" : [ 11, 8, 11, 8 ],
"name" : "a"
},
"operator" : "*",
"right" : {
"kind" : "Identifier",
"location" : [ 11, 12, 11, 12 ],
"name" : "x"
}
}
}, {
"kind" : "ReturnStmt",
"location" : [ 12, 4, 12, 16 ],
"value" : {
"kind" : "CallExpr",
"location" : [ 12, 11, 12, 16 ],
"function" : {
"kind" : "Identifier",
"location" : [ 12, 11, 12, 11 ],
"name" : "f"
},
"args" : [ {
"kind" : "BinaryExpr",
"location" : [ 12, 13, 12, 15 ],
"left" : {
"kind" : "Identifier",
"location" : [ 12, 13, 12, 13 ],
"name" : "i"
},
"operator" : "-",
"right" : {
"kind" : "IntegerLiteral",
"location" : [ 12, 15, 12, 15 ],
"value" : 1
}
} ]
}
} ]
} ]
} ],
"statements" : [ {
"kind" : "AssignStmt",
"location" : [ 13, 2, 13, 6 ],
"targets" : [ {
"kind" : "Identifier",
"location" : [ 13, 2, 13, 2 ],
"name" : "a"
} ],
"value" : {
"kind" : "IntegerLiteral",
"location" : [ 13, 6, 13, 6 ],
"value" : 1
}
}, {
"kind" : "ReturnStmt",
"location" : [ 14, 2, 14, 12 ],
"value" : {
"kind" : "CallExpr",
"location" : [ 14, 9, 14, 12 ],
"function" : {
"kind" : "Identifier",
"location" : [ 14, 9, 14, 9 ],
"name" : "f"
},
"args" : [ {
"kind" : "Identifier",
"location" : [ 14, 11, 14, 11 ],
"name" : "y"
} ]
}
} ]
}, {
"kind" : "VarDef",
"location" : [ 17, 1, 17, 10 ],
"var" : {
"kind" : "TypedVar",
"location" : [ 17, 1, 17, 5 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 17, 1, 17, 1 ],
"name" : "n"
},
"type" : {
"kind" : "ClassType",
"location" : [ 17, 3, 17, 5 ],
"className" : "int"
}
},
"value" : {
"kind" : "IntegerLiteral",
"location" : [ 17, 9, 17, 10 ],
"value" : 42
}
}, {
"kind" : "VarDef",
"location" : [ 20, 1, 20, 9 ],
"var" : {
"kind" : "TypedVar",
"location" : [ 20, 1, 20, 5 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 20, 1, 20, 1 ],
"name" : "i"
},
"type" : {
"kind" : "ClassType",
"location" : [ 20, 3, 20, 5 ],
"className" : "int"
}
},
"value" : {
"kind" : "IntegerLiteral",
"location" : [ 20, 9, 20, 9 ],
"value" : 0
}
} ],
"statements" : [ {
"kind" : "WhileStmt",
"location" : [ 23, 1, 26, 1 ],
"condition" : {
"kind" : "BinaryExpr",
"location" : [ 23, 7, 23, 12 ],
"left" : {
"kind" : "Identifier",
"location" : [ 23, 7, 23, 7 ],
"name" : "i"
},
"operator" : "<=",
"right" : {
"kind" : "Identifier",
"location" : [ 23, 12, 23, 12 ],
"name" : "n"
}
},
"body" : [ {
"kind" : "ExprStmt",
"location" : [ 24, 2, 24, 22 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 24, 2, 24, 22 ],
"function" : {
"kind" : "Identifier",
"location" : [ 24, 2, 24, 6 ],
"name" : "print"
},
"args" : [ {
"kind" : "CallExpr",
"location" : [ 24, 8, 24, 21 ],
"function" : {
"kind" : "Identifier",
"location" : [ 24, 8, 24, 10 ],
"name" : "exp"
},
"args" : [ {
"kind" : "IntegerLiteral",
"location" : [ 24, 12, 24, 12 ],
"value" : 2
}, {
"kind" : "BinaryExpr",
"location" : [ 24, 15, 24, 20 ],
"left" : {
"kind" : "Identifier",
"location" : [ 24, 15, 24, 15 ],
"name" : "i"
},
"operator" : "%",
"right" : {
"kind" : "IntegerLiteral",
"location" : [ 24, 19, 24, 20 ],
"value" : 31
}
} ]
} ]
}
}, {
"kind" : "AssignStmt",
"location" : [ 25, 2, 25, 10 ],
"targets" : [ {
"kind" : "Identifier",
"location" : [ 25, 2, 25, 2 ],
"name" : "i"
} ],
"value" : {
"kind" : "BinaryExpr",
"location" : [ 25, 6, 25, 10 ],
"left" : {
"kind" : "Identifier",
"location" : [ 25, 6, 25, 6 ],
"name" : "i"
},
"operator" : "+",
"right" : {
"kind" : "IntegerLiteral",
"location" : [ 25, 10, 25, 10 ],
"value" : 1
}
}
} ]
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}