disclose hiden tests

This commit is contained in:
ldXiao
2021-03-12 09:39:57 -05:00
parent 044a8a2efd
commit 9446453747
75 changed files with 6562 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
x = (y = 2)
+16
View File
@@ -0,0 +1,16 @@
{
"kind" : "Program",
"location" : [ 1, 6, 1, 6 ],
"declarations" : [ ],
"statements" : [ ],
"errors" : {
"errors" : [ {
"kind" : "CompilerError",
"location" : [ 1, 8, 1, 8 ],
"message" : "Parse error near token EQ: =",
"syntax" : true
} ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}
+1
View File
@@ -0,0 +1 @@
print(x = 1)
+16
View File
@@ -0,0 +1,16 @@
{
"kind" : "Program",
"location" : [ 1, 7, 1, 7 ],
"declarations" : [ ],
"statements" : [ ],
"errors" : {
"errors" : [ {
"kind" : "CompilerError",
"location" : [ 1, 9, 1, 9 ],
"message" : "Parse error near token EQ: =",
"syntax" : true
} ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}
+6
View File
@@ -0,0 +1,6 @@
def foo(a, b) -> 1:
x:int = a
return 1
print(1)
print(3**6)
+64
View File
@@ -0,0 +1,64 @@
{
"kind" : "Program",
"location" : [ 2, 13, 6, 8 ],
"declarations" : [ ],
"statements" : [ {
"kind" : "ExprStmt",
"location" : [ 2, 13, 2, 13 ],
"expr" : {
"kind" : "Identifier",
"location" : [ 2, 13, 2, 13 ],
"name" : "a"
}
}, {
"kind" : "ReturnStmt",
"location" : [ 3, 5, 3, 12 ],
"value" : {
"kind" : "IntegerLiteral",
"location" : [ 3, 12, 3, 12 ],
"value" : 1
}
}, {
"kind" : "ExprStmt",
"location" : [ 5, 1, 5, 8 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 5, 1, 5, 8 ],
"function" : {
"kind" : "Identifier",
"location" : [ 5, 1, 5, 5 ],
"name" : "print"
},
"args" : [ {
"kind" : "IntegerLiteral",
"location" : [ 5, 7, 5, 7 ],
"value" : 1
} ]
}
} ],
"errors" : {
"errors" : [ {
"kind" : "CompilerError",
"location" : [ 1, 10, 1, 10 ],
"message" : "Parse error near token COMMA: ,",
"syntax" : true
}, {
"kind" : "CompilerError",
"location" : [ 2, 13, 2, 13 ],
"message" : "Parse error near token IDENTIFIER: a",
"syntax" : true
}, {
"kind" : "CompilerError",
"location" : [ 5, 1, 5, 0 ],
"message" : "Parse error near token DEDENT: ",
"syntax" : true
}, {
"kind" : "CompilerError",
"location" : [ 6, 9, 6, 9 ],
"message" : "Parse error near token TIMES: *",
"syntax" : true
} ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}
+3
View File
@@ -0,0 +1,3 @@
x = 1
y = 2
z = 3
+47
View File
@@ -0,0 +1,47 @@
{
"kind" : "Program",
"location" : [ 2, 3, 3, 6 ],
"declarations" : [ ],
"statements" : [ {
"kind" : "AssignStmt",
"location" : [ 2, 3, 2, 7 ],
"targets" : [ {
"kind" : "Identifier",
"location" : [ 2, 3, 2, 3 ],
"name" : "y"
} ],
"value" : {
"kind" : "IntegerLiteral",
"location" : [ 2, 7, 2, 7 ],
"value" : 2
}
}, {
"kind" : "AssignStmt",
"location" : [ 3, 1, 3, 5 ],
"targets" : [ {
"kind" : "Identifier",
"location" : [ 3, 1, 3, 1 ],
"name" : "z"
} ],
"value" : {
"kind" : "IntegerLiteral",
"location" : [ 3, 5, 3, 5 ],
"value" : 3
}
} ],
"errors" : {
"errors" : [ {
"kind" : "CompilerError",
"location" : [ 2, 1, 2, 2 ],
"message" : "Parse error near token INDENT: ",
"syntax" : true
}, {
"kind" : "CompilerError",
"location" : [ 3, 1, 3, 0 ],
"message" : "Parse error near token DEDENT: ",
"syntax" : true
} ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}
+4
View File
@@ -0,0 +1,4 @@
1 + 2
3 == 4 or (not False && True)
5 + 6
7 << 8
+65
View File
@@ -0,0 +1,65 @@
{
"kind" : "Program",
"location" : [ 1, 1, 4, 7 ],
"declarations" : [ ],
"statements" : [ {
"kind" : "ExprStmt",
"location" : [ 1, 1, 1, 5 ],
"expr" : {
"kind" : "BinaryExpr",
"location" : [ 1, 1, 1, 5 ],
"left" : {
"kind" : "IntegerLiteral",
"location" : [ 1, 1, 1, 1 ],
"value" : 1
},
"operator" : "+",
"right" : {
"kind" : "IntegerLiteral",
"location" : [ 1, 5, 1, 5 ],
"value" : 2
}
}
}, {
"kind" : "ExprStmt",
"location" : [ 3, 1, 3, 5 ],
"expr" : {
"kind" : "BinaryExpr",
"location" : [ 3, 1, 3, 5 ],
"left" : {
"kind" : "IntegerLiteral",
"location" : [ 3, 1, 3, 1 ],
"value" : 5
},
"operator" : "+",
"right" : {
"kind" : "IntegerLiteral",
"location" : [ 3, 5, 3, 5 ],
"value" : 6
}
}
}, {
"kind" : "ExprStmt",
"location" : [ 4, 6, 4, 6 ],
"expr" : {
"kind" : "IntegerLiteral",
"location" : [ 4, 6, 4, 6 ],
"value" : 8
}
} ],
"errors" : {
"errors" : [ {
"kind" : "CompilerError",
"location" : [ 2, 22, 2, 22 ],
"message" : "Parse error near token UNRECOGNIZED: &",
"syntax" : true
}, {
"kind" : "CompilerError",
"location" : [ 4, 4, 4, 4 ],
"message" : "Parse error near token LT: <",
"syntax" : true
} ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}
@@ -0,0 +1,2 @@
x[0] = y = z.f = 1
z.g = y = x[0]
@@ -0,0 +1,85 @@
{
"kind" : "Program",
"location" : [ 1, 1, 2, 15 ],
"declarations" : [ ],
"statements" : [ {
"kind" : "AssignStmt",
"location" : [ 1, 1, 1, 18 ],
"targets" : [ {
"kind" : "IndexExpr",
"location" : [ 1, 1, 1, 4 ],
"list" : {
"kind" : "Identifier",
"location" : [ 1, 1, 1, 1 ],
"name" : "x"
},
"index" : {
"kind" : "IntegerLiteral",
"location" : [ 1, 3, 1, 3 ],
"value" : 0
}
}, {
"kind" : "Identifier",
"location" : [ 1, 8, 1, 8 ],
"name" : "y"
}, {
"kind" : "MemberExpr",
"location" : [ 1, 12, 1, 14 ],
"object" : {
"kind" : "Identifier",
"location" : [ 1, 12, 1, 12 ],
"name" : "z"
},
"member" : {
"kind" : "Identifier",
"location" : [ 1, 14, 1, 14 ],
"name" : "f"
}
} ],
"value" : {
"kind" : "IntegerLiteral",
"location" : [ 1, 18, 1, 18 ],
"value" : 1
}
}, {
"kind" : "AssignStmt",
"location" : [ 2, 1, 2, 14 ],
"targets" : [ {
"kind" : "MemberExpr",
"location" : [ 2, 1, 2, 3 ],
"object" : {
"kind" : "Identifier",
"location" : [ 2, 1, 2, 1 ],
"name" : "z"
},
"member" : {
"kind" : "Identifier",
"location" : [ 2, 3, 2, 3 ],
"name" : "g"
}
}, {
"kind" : "Identifier",
"location" : [ 2, 7, 2, 7 ],
"name" : "y"
} ],
"value" : {
"kind" : "IndexExpr",
"location" : [ 2, 11, 2, 14 ],
"list" : {
"kind" : "Identifier",
"location" : [ 2, 11, 2, 11 ],
"name" : "x"
},
"index" : {
"kind" : "IntegerLiteral",
"location" : [ 2, 13, 2, 13 ],
"value" : 0
}
}
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}
@@ -0,0 +1 @@
x = y = z = 1
@@ -0,0 +1,32 @@
{
"kind" : "Program",
"location" : [ 1, 1, 1, 14 ],
"declarations" : [ ],
"statements" : [ {
"kind" : "AssignStmt",
"location" : [ 1, 1, 1, 13 ],
"targets" : [ {
"kind" : "Identifier",
"location" : [ 1, 1, 1, 1 ],
"name" : "x"
}, {
"kind" : "Identifier",
"location" : [ 1, 5, 1, 5 ],
"name" : "y"
}, {
"kind" : "Identifier",
"location" : [ 1, 9, 1, 9 ],
"name" : "z"
} ],
"value" : {
"kind" : "IntegerLiteral",
"location" : [ 1, 13, 1, 13 ],
"value" : 1
}
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}
+4
View File
@@ -0,0 +1,4 @@
class Foo(object):
x:int = 1
f = Foo()
+65
View File
@@ -0,0 +1,65 @@
{
"kind" : "Program",
"location" : [ 1, 1, 4, 10 ],
"declarations" : [ {
"kind" : "ClassDef",
"location" : [ 1, 1, 2, 14 ],
"name" : {
"kind" : "Identifier",
"location" : [ 1, 7, 1, 9 ],
"name" : "Foo"
},
"superClass" : {
"kind" : "Identifier",
"location" : [ 1, 11, 1, 16 ],
"name" : "object"
},
"declarations" : [ {
"kind" : "VarDef",
"location" : [ 2, 5, 2, 13 ],
"var" : {
"kind" : "TypedVar",
"location" : [ 2, 5, 2, 9 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 2, 5, 2, 5 ],
"name" : "x"
},
"type" : {
"kind" : "ClassType",
"location" : [ 2, 7, 2, 9 ],
"className" : "int"
}
},
"value" : {
"kind" : "IntegerLiteral",
"location" : [ 2, 13, 2, 13 ],
"value" : 1
}
} ]
} ],
"statements" : [ {
"kind" : "AssignStmt",
"location" : [ 4, 1, 4, 9 ],
"targets" : [ {
"kind" : "Identifier",
"location" : [ 4, 1, 4, 1 ],
"name" : "f"
} ],
"value" : {
"kind" : "CallExpr",
"location" : [ 4, 5, 4, 9 ],
"function" : {
"kind" : "Identifier",
"location" : [ 4, 5, 4, 7 ],
"name" : "Foo"
},
"args" : [ ]
}
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}
+5
View File
@@ -0,0 +1,5 @@
class Foo(object):
x:int = 1
f = Foo()
print(f.x)
+91
View File
@@ -0,0 +1,91 @@
{
"kind" : "Program",
"location" : [ 1, 1, 5, 11 ],
"declarations" : [ {
"kind" : "ClassDef",
"location" : [ 1, 1, 2, 14 ],
"name" : {
"kind" : "Identifier",
"location" : [ 1, 7, 1, 9 ],
"name" : "Foo"
},
"superClass" : {
"kind" : "Identifier",
"location" : [ 1, 11, 1, 16 ],
"name" : "object"
},
"declarations" : [ {
"kind" : "VarDef",
"location" : [ 2, 5, 2, 13 ],
"var" : {
"kind" : "TypedVar",
"location" : [ 2, 5, 2, 9 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 2, 5, 2, 5 ],
"name" : "x"
},
"type" : {
"kind" : "ClassType",
"location" : [ 2, 7, 2, 9 ],
"className" : "int"
}
},
"value" : {
"kind" : "IntegerLiteral",
"location" : [ 2, 13, 2, 13 ],
"value" : 1
}
} ]
} ],
"statements" : [ {
"kind" : "AssignStmt",
"location" : [ 4, 1, 4, 9 ],
"targets" : [ {
"kind" : "Identifier",
"location" : [ 4, 1, 4, 1 ],
"name" : "f"
} ],
"value" : {
"kind" : "CallExpr",
"location" : [ 4, 5, 4, 9 ],
"function" : {
"kind" : "Identifier",
"location" : [ 4, 5, 4, 7 ],
"name" : "Foo"
},
"args" : [ ]
}
}, {
"kind" : "ExprStmt",
"location" : [ 5, 1, 5, 10 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 5, 1, 5, 10 ],
"function" : {
"kind" : "Identifier",
"location" : [ 5, 1, 5, 5 ],
"name" : "print"
},
"args" : [ {
"kind" : "MemberExpr",
"location" : [ 5, 7, 5, 9 ],
"object" : {
"kind" : "Identifier",
"location" : [ 5, 7, 5, 7 ],
"name" : "f"
},
"member" : {
"kind" : "Identifier",
"location" : [ 5, 9, 5, 9 ],
"name" : "x"
}
} ]
}
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}
+5
View File
@@ -0,0 +1,5 @@
class Foo(object):
x:int = 1
f = Foo()
f.x = 2
+87
View File
@@ -0,0 +1,87 @@
{
"kind" : "Program",
"location" : [ 1, 1, 5, 8 ],
"declarations" : [ {
"kind" : "ClassDef",
"location" : [ 1, 1, 2, 14 ],
"name" : {
"kind" : "Identifier",
"location" : [ 1, 7, 1, 9 ],
"name" : "Foo"
},
"superClass" : {
"kind" : "Identifier",
"location" : [ 1, 11, 1, 16 ],
"name" : "object"
},
"declarations" : [ {
"kind" : "VarDef",
"location" : [ 2, 5, 2, 13 ],
"var" : {
"kind" : "TypedVar",
"location" : [ 2, 5, 2, 9 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 2, 5, 2, 5 ],
"name" : "x"
},
"type" : {
"kind" : "ClassType",
"location" : [ 2, 7, 2, 9 ],
"className" : "int"
}
},
"value" : {
"kind" : "IntegerLiteral",
"location" : [ 2, 13, 2, 13 ],
"value" : 1
}
} ]
} ],
"statements" : [ {
"kind" : "AssignStmt",
"location" : [ 4, 1, 4, 9 ],
"targets" : [ {
"kind" : "Identifier",
"location" : [ 4, 1, 4, 1 ],
"name" : "f"
} ],
"value" : {
"kind" : "CallExpr",
"location" : [ 4, 5, 4, 9 ],
"function" : {
"kind" : "Identifier",
"location" : [ 4, 5, 4, 7 ],
"name" : "Foo"
},
"args" : [ ]
}
}, {
"kind" : "AssignStmt",
"location" : [ 5, 1, 5, 7 ],
"targets" : [ {
"kind" : "MemberExpr",
"location" : [ 5, 1, 5, 3 ],
"object" : {
"kind" : "Identifier",
"location" : [ 5, 1, 5, 1 ],
"name" : "f"
},
"member" : {
"kind" : "Identifier",
"location" : [ 5, 3, 5, 3 ],
"name" : "x"
}
} ],
"value" : {
"kind" : "IntegerLiteral",
"location" : [ 5, 7, 5, 7 ],
"value" : 2
}
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}
+8
View File
@@ -0,0 +1,8 @@
class Foo(object):
x:int = 0
def __init__(self:"Foo", x:int):
self.x = x
f = Foo(1)
print(f.x)
+159
View File
@@ -0,0 +1,159 @@
{
"kind" : "Program",
"location" : [ 1, 1, 8, 11 ],
"declarations" : [ {
"kind" : "ClassDef",
"location" : [ 1, 1, 7, 0 ],
"name" : {
"kind" : "Identifier",
"location" : [ 1, 7, 1, 9 ],
"name" : "Foo"
},
"superClass" : {
"kind" : "Identifier",
"location" : [ 1, 11, 1, 16 ],
"name" : "object"
},
"declarations" : [ {
"kind" : "VarDef",
"location" : [ 2, 5, 2, 13 ],
"var" : {
"kind" : "TypedVar",
"location" : [ 2, 5, 2, 9 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 2, 5, 2, 5 ],
"name" : "x"
},
"type" : {
"kind" : "ClassType",
"location" : [ 2, 7, 2, 9 ],
"className" : "int"
}
},
"value" : {
"kind" : "IntegerLiteral",
"location" : [ 2, 13, 2, 13 ],
"value" : 0
}
}, {
"kind" : "FuncDef",
"location" : [ 4, 5, 5, 19 ],
"name" : {
"kind" : "Identifier",
"location" : [ 4, 9, 4, 16 ],
"name" : "__init__"
},
"params" : [ {
"kind" : "TypedVar",
"location" : [ 4, 18, 4, 27 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 4, 18, 4, 21 ],
"name" : "self"
},
"type" : {
"kind" : "ClassType",
"location" : [ 4, 23, 4, 27 ],
"className" : "Foo"
}
}, {
"kind" : "TypedVar",
"location" : [ 4, 30, 4, 34 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 4, 30, 4, 30 ],
"name" : "x"
},
"type" : {
"kind" : "ClassType",
"location" : [ 4, 32, 4, 34 ],
"className" : "int"
}
} ],
"returnType" : {
"kind" : "ClassType",
"location" : [ 4, 36, 4, 36 ],
"className" : "<None>"
},
"declarations" : [ ],
"statements" : [ {
"kind" : "AssignStmt",
"location" : [ 5, 9, 5, 18 ],
"targets" : [ {
"kind" : "MemberExpr",
"location" : [ 5, 9, 5, 14 ],
"object" : {
"kind" : "Identifier",
"location" : [ 5, 9, 5, 12 ],
"name" : "self"
},
"member" : {
"kind" : "Identifier",
"location" : [ 5, 14, 5, 14 ],
"name" : "x"
}
} ],
"value" : {
"kind" : "Identifier",
"location" : [ 5, 18, 5, 18 ],
"name" : "x"
}
} ]
} ]
} ],
"statements" : [ {
"kind" : "AssignStmt",
"location" : [ 7, 1, 7, 10 ],
"targets" : [ {
"kind" : "Identifier",
"location" : [ 7, 1, 7, 1 ],
"name" : "f"
} ],
"value" : {
"kind" : "CallExpr",
"location" : [ 7, 5, 7, 10 ],
"function" : {
"kind" : "Identifier",
"location" : [ 7, 5, 7, 7 ],
"name" : "Foo"
},
"args" : [ {
"kind" : "IntegerLiteral",
"location" : [ 7, 9, 7, 9 ],
"value" : 1
} ]
}
}, {
"kind" : "ExprStmt",
"location" : [ 8, 1, 8, 10 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 8, 1, 8, 10 ],
"function" : {
"kind" : "Identifier",
"location" : [ 8, 1, 8, 5 ],
"name" : "print"
},
"args" : [ {
"kind" : "MemberExpr",
"location" : [ 8, 7, 8, 9 ],
"object" : {
"kind" : "Identifier",
"location" : [ 8, 7, 8, 7 ],
"name" : "f"
},
"member" : {
"kind" : "Identifier",
"location" : [ 8, 9, 8, 9 ],
"name" : "x"
}
} ]
}
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}
+9
View File
@@ -0,0 +1,9 @@
class Foo(object):
x:int = 0
def set(self:"Foo", x:int) -> object:
self.x = x
f = Foo()
f.set(1)
print(f.x)
+181
View File
@@ -0,0 +1,181 @@
{
"kind" : "Program",
"location" : [ 1, 1, 9, 11 ],
"declarations" : [ {
"kind" : "ClassDef",
"location" : [ 1, 1, 7, 0 ],
"name" : {
"kind" : "Identifier",
"location" : [ 1, 7, 1, 9 ],
"name" : "Foo"
},
"superClass" : {
"kind" : "Identifier",
"location" : [ 1, 11, 1, 16 ],
"name" : "object"
},
"declarations" : [ {
"kind" : "VarDef",
"location" : [ 2, 5, 2, 13 ],
"var" : {
"kind" : "TypedVar",
"location" : [ 2, 5, 2, 9 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 2, 5, 2, 5 ],
"name" : "x"
},
"type" : {
"kind" : "ClassType",
"location" : [ 2, 7, 2, 9 ],
"className" : "int"
}
},
"value" : {
"kind" : "IntegerLiteral",
"location" : [ 2, 13, 2, 13 ],
"value" : 0
}
}, {
"kind" : "FuncDef",
"location" : [ 4, 5, 5, 19 ],
"name" : {
"kind" : "Identifier",
"location" : [ 4, 9, 4, 11 ],
"name" : "set"
},
"params" : [ {
"kind" : "TypedVar",
"location" : [ 4, 13, 4, 22 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 4, 13, 4, 16 ],
"name" : "self"
},
"type" : {
"kind" : "ClassType",
"location" : [ 4, 18, 4, 22 ],
"className" : "Foo"
}
}, {
"kind" : "TypedVar",
"location" : [ 4, 25, 4, 29 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 4, 25, 4, 25 ],
"name" : "x"
},
"type" : {
"kind" : "ClassType",
"location" : [ 4, 27, 4, 29 ],
"className" : "int"
}
} ],
"returnType" : {
"kind" : "ClassType",
"location" : [ 4, 35, 4, 40 ],
"className" : "object"
},
"declarations" : [ ],
"statements" : [ {
"kind" : "AssignStmt",
"location" : [ 5, 9, 5, 18 ],
"targets" : [ {
"kind" : "MemberExpr",
"location" : [ 5, 9, 5, 14 ],
"object" : {
"kind" : "Identifier",
"location" : [ 5, 9, 5, 12 ],
"name" : "self"
},
"member" : {
"kind" : "Identifier",
"location" : [ 5, 14, 5, 14 ],
"name" : "x"
}
} ],
"value" : {
"kind" : "Identifier",
"location" : [ 5, 18, 5, 18 ],
"name" : "x"
}
} ]
} ]
} ],
"statements" : [ {
"kind" : "AssignStmt",
"location" : [ 7, 1, 7, 9 ],
"targets" : [ {
"kind" : "Identifier",
"location" : [ 7, 1, 7, 1 ],
"name" : "f"
} ],
"value" : {
"kind" : "CallExpr",
"location" : [ 7, 5, 7, 9 ],
"function" : {
"kind" : "Identifier",
"location" : [ 7, 5, 7, 7 ],
"name" : "Foo"
},
"args" : [ ]
}
}, {
"kind" : "ExprStmt",
"location" : [ 8, 1, 8, 8 ],
"expr" : {
"kind" : "MethodCallExpr",
"location" : [ 8, 1, 8, 8 ],
"method" : {
"kind" : "MemberExpr",
"location" : [ 8, 1, 8, 5 ],
"object" : {
"kind" : "Identifier",
"location" : [ 8, 1, 8, 1 ],
"name" : "f"
},
"member" : {
"kind" : "Identifier",
"location" : [ 8, 3, 8, 5 ],
"name" : "set"
}
},
"args" : [ {
"kind" : "IntegerLiteral",
"location" : [ 8, 7, 8, 7 ],
"value" : 1
} ]
}
}, {
"kind" : "ExprStmt",
"location" : [ 9, 1, 9, 10 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 9, 1, 9, 10 ],
"function" : {
"kind" : "Identifier",
"location" : [ 9, 1, 9, 5 ],
"name" : "print"
},
"args" : [ {
"kind" : "MemberExpr",
"location" : [ 9, 7, 9, 9 ],
"object" : {
"kind" : "Identifier",
"location" : [ 9, 7, 9, 7 ],
"name" : "f"
},
"member" : {
"kind" : "Identifier",
"location" : [ 9, 9, 9, 9 ],
"name" : "x"
}
} ]
}
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}
+38
View File
@@ -0,0 +1,38 @@
count:int = 0
def foo(s: str) -> int:
return len(s)
class bar(object):
p: bool = True
def baz(self:"bar", xx: [int]) -> str:
global count
x:int = 0
y:int = 1
def qux(y: int) -> object:
nonlocal x
if x > y:
x = -1
for x in xx:
self.p = x == 2
qux(0) # Yay! ChocoPy
count = count + 1
while x <= 0:
if self.p:
xx[0] = xx[1]
self.p = not self.p
x = x + 1
elif foo("Long"[0]) == 1:
return self is None
return "Nope"
print(bar().baz([1,2]))
+613
View File
@@ -0,0 +1,613 @@
{
"kind" : "Program",
"location" : [ 1, 1, 36, 24 ],
"declarations" : [ {
"kind" : "VarDef",
"location" : [ 1, 1, 1, 13 ],
"var" : {
"kind" : "TypedVar",
"location" : [ 1, 1, 1, 9 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 1, 1, 1, 5 ],
"name" : "count"
},
"type" : {
"kind" : "ClassType",
"location" : [ 1, 7, 1, 9 ],
"className" : "int"
}
},
"value" : {
"kind" : "IntegerLiteral",
"location" : [ 1, 13, 1, 13 ],
"value" : 0
}
}, {
"kind" : "FuncDef",
"location" : [ 3, 1, 4, 18 ],
"name" : {
"kind" : "Identifier",
"location" : [ 3, 5, 3, 7 ],
"name" : "foo"
},
"params" : [ {
"kind" : "TypedVar",
"location" : [ 3, 9, 3, 14 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 3, 9, 3, 9 ],
"name" : "s"
},
"type" : {
"kind" : "ClassType",
"location" : [ 3, 12, 3, 14 ],
"className" : "str"
}
} ],
"returnType" : {
"kind" : "ClassType",
"location" : [ 3, 20, 3, 22 ],
"className" : "int"
},
"declarations" : [ ],
"statements" : [ {
"kind" : "ReturnStmt",
"location" : [ 4, 5, 4, 17 ],
"value" : {
"kind" : "CallExpr",
"location" : [ 4, 12, 4, 17 ],
"function" : {
"kind" : "Identifier",
"location" : [ 4, 12, 4, 14 ],
"name" : "len"
},
"args" : [ {
"kind" : "Identifier",
"location" : [ 4, 16, 4, 16 ],
"name" : "s"
} ]
}
} ]
}, {
"kind" : "ClassDef",
"location" : [ 6, 1, 36, 0 ],
"name" : {
"kind" : "Identifier",
"location" : [ 6, 7, 6, 9 ],
"name" : "bar"
},
"superClass" : {
"kind" : "Identifier",
"location" : [ 6, 11, 6, 16 ],
"name" : "object"
},
"declarations" : [ {
"kind" : "VarDef",
"location" : [ 7, 5, 7, 18 ],
"var" : {
"kind" : "TypedVar",
"location" : [ 7, 5, 7, 11 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 7, 5, 7, 5 ],
"name" : "p"
},
"type" : {
"kind" : "ClassType",
"location" : [ 7, 8, 7, 11 ],
"className" : "bool"
}
},
"value" : {
"kind" : "BooleanLiteral",
"location" : [ 7, 15, 7, 18 ],
"value" : true
}
}, {
"kind" : "FuncDef",
"location" : [ 9, 5, 34, 22 ],
"name" : {
"kind" : "Identifier",
"location" : [ 9, 9, 9, 11 ],
"name" : "baz"
},
"params" : [ {
"kind" : "TypedVar",
"location" : [ 9, 13, 9, 22 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 9, 13, 9, 16 ],
"name" : "self"
},
"type" : {
"kind" : "ClassType",
"location" : [ 9, 18, 9, 22 ],
"className" : "bar"
}
}, {
"kind" : "TypedVar",
"location" : [ 9, 25, 9, 33 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 9, 25, 9, 26 ],
"name" : "xx"
},
"type" : {
"kind" : "ListType",
"location" : [ 9, 29, 9, 33 ],
"elementType" : {
"kind" : "ClassType",
"location" : [ 9, 30, 9, 32 ],
"className" : "int"
}
}
} ],
"returnType" : {
"kind" : "ClassType",
"location" : [ 9, 39, 9, 41 ],
"className" : "str"
},
"declarations" : [ {
"kind" : "GlobalDecl",
"location" : [ 10, 9, 10, 20 ],
"variable" : {
"kind" : "Identifier",
"location" : [ 10, 16, 10, 20 ],
"name" : "count"
}
}, {
"kind" : "VarDef",
"location" : [ 11, 9, 11, 17 ],
"var" : {
"kind" : "TypedVar",
"location" : [ 11, 9, 11, 13 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 11, 9, 11, 9 ],
"name" : "x"
},
"type" : {
"kind" : "ClassType",
"location" : [ 11, 11, 11, 13 ],
"className" : "int"
}
},
"value" : {
"kind" : "IntegerLiteral",
"location" : [ 11, 17, 11, 17 ],
"value" : 0
}
}, {
"kind" : "VarDef",
"location" : [ 12, 9, 12, 17 ],
"var" : {
"kind" : "TypedVar",
"location" : [ 12, 9, 12, 13 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 12, 9, 12, 9 ],
"name" : "y"
},
"type" : {
"kind" : "ClassType",
"location" : [ 12, 11, 12, 13 ],
"className" : "int"
}
},
"value" : {
"kind" : "IntegerLiteral",
"location" : [ 12, 17, 12, 17 ],
"value" : 1
}
}, {
"kind" : "FuncDef",
"location" : [ 14, 9, 19, 8 ],
"name" : {
"kind" : "Identifier",
"location" : [ 14, 13, 14, 15 ],
"name" : "qux"
},
"params" : [ {
"kind" : "TypedVar",
"location" : [ 14, 17, 14, 22 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 14, 17, 14, 17 ],
"name" : "y"
},
"type" : {
"kind" : "ClassType",
"location" : [ 14, 20, 14, 22 ],
"className" : "int"
}
} ],
"returnType" : {
"kind" : "ClassType",
"location" : [ 14, 28, 14, 33 ],
"className" : "object"
},
"declarations" : [ {
"kind" : "NonLocalDecl",
"location" : [ 15, 13, 15, 22 ],
"variable" : {
"kind" : "Identifier",
"location" : [ 15, 22, 15, 22 ],
"name" : "x"
}
} ],
"statements" : [ {
"kind" : "IfStmt",
"location" : [ 16, 13, 19, 8 ],
"condition" : {
"kind" : "BinaryExpr",
"location" : [ 16, 16, 16, 20 ],
"left" : {
"kind" : "Identifier",
"location" : [ 16, 16, 16, 16 ],
"name" : "x"
},
"operator" : ">",
"right" : {
"kind" : "Identifier",
"location" : [ 16, 20, 16, 20 ],
"name" : "y"
}
},
"thenBody" : [ {
"kind" : "AssignStmt",
"location" : [ 17, 17, 17, 22 ],
"targets" : [ {
"kind" : "Identifier",
"location" : [ 17, 17, 17, 17 ],
"name" : "x"
} ],
"value" : {
"kind" : "UnaryExpr",
"location" : [ 17, 21, 17, 22 ],
"operator" : "-",
"operand" : {
"kind" : "IntegerLiteral",
"location" : [ 17, 22, 17, 22 ],
"value" : 1
}
}
} ],
"elseBody" : [ ]
} ]
} ],
"statements" : [ {
"kind" : "ForStmt",
"location" : [ 19, 9, 22, 8 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 19, 13, 19, 13 ],
"name" : "x"
},
"iterable" : {
"kind" : "Identifier",
"location" : [ 19, 18, 19, 19 ],
"name" : "xx"
},
"body" : [ {
"kind" : "AssignStmt",
"location" : [ 20, 13, 20, 27 ],
"targets" : [ {
"kind" : "MemberExpr",
"location" : [ 20, 13, 20, 18 ],
"object" : {
"kind" : "Identifier",
"location" : [ 20, 13, 20, 16 ],
"name" : "self"
},
"member" : {
"kind" : "Identifier",
"location" : [ 20, 18, 20, 18 ],
"name" : "p"
}
} ],
"value" : {
"kind" : "BinaryExpr",
"location" : [ 20, 22, 20, 27 ],
"left" : {
"kind" : "Identifier",
"location" : [ 20, 22, 20, 22 ],
"name" : "x"
},
"operator" : "==",
"right" : {
"kind" : "IntegerLiteral",
"location" : [ 20, 27, 20, 27 ],
"value" : 2
}
}
} ]
}, {
"kind" : "ExprStmt",
"location" : [ 22, 9, 22, 14 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 22, 9, 22, 14 ],
"function" : {
"kind" : "Identifier",
"location" : [ 22, 9, 22, 11 ],
"name" : "qux"
},
"args" : [ {
"kind" : "IntegerLiteral",
"location" : [ 22, 13, 22, 13 ],
"value" : 0
} ]
}
}, {
"kind" : "AssignStmt",
"location" : [ 24, 9, 24, 25 ],
"targets" : [ {
"kind" : "Identifier",
"location" : [ 24, 9, 24, 13 ],
"name" : "count"
} ],
"value" : {
"kind" : "BinaryExpr",
"location" : [ 24, 17, 24, 25 ],
"left" : {
"kind" : "Identifier",
"location" : [ 24, 17, 24, 21 ],
"name" : "count"
},
"operator" : "+",
"right" : {
"kind" : "IntegerLiteral",
"location" : [ 24, 25, 24, 25 ],
"value" : 1
}
}
}, {
"kind" : "WhileStmt",
"location" : [ 26, 9, 34, 8 ],
"condition" : {
"kind" : "BinaryExpr",
"location" : [ 26, 15, 26, 20 ],
"left" : {
"kind" : "Identifier",
"location" : [ 26, 15, 26, 15 ],
"name" : "x"
},
"operator" : "<=",
"right" : {
"kind" : "IntegerLiteral",
"location" : [ 26, 20, 26, 20 ],
"value" : 0
}
},
"body" : [ {
"kind" : "IfStmt",
"location" : [ 27, 13, 34, 8 ],
"condition" : {
"kind" : "MemberExpr",
"location" : [ 27, 16, 27, 21 ],
"object" : {
"kind" : "Identifier",
"location" : [ 27, 16, 27, 19 ],
"name" : "self"
},
"member" : {
"kind" : "Identifier",
"location" : [ 27, 21, 27, 21 ],
"name" : "p"
}
},
"thenBody" : [ {
"kind" : "AssignStmt",
"location" : [ 28, 17, 28, 29 ],
"targets" : [ {
"kind" : "IndexExpr",
"location" : [ 28, 17, 28, 21 ],
"list" : {
"kind" : "Identifier",
"location" : [ 28, 17, 28, 18 ],
"name" : "xx"
},
"index" : {
"kind" : "IntegerLiteral",
"location" : [ 28, 20, 28, 20 ],
"value" : 0
}
} ],
"value" : {
"kind" : "IndexExpr",
"location" : [ 28, 25, 28, 29 ],
"list" : {
"kind" : "Identifier",
"location" : [ 28, 25, 28, 26 ],
"name" : "xx"
},
"index" : {
"kind" : "IntegerLiteral",
"location" : [ 28, 28, 28, 28 ],
"value" : 1
}
}
}, {
"kind" : "AssignStmt",
"location" : [ 29, 17, 29, 35 ],
"targets" : [ {
"kind" : "MemberExpr",
"location" : [ 29, 17, 29, 22 ],
"object" : {
"kind" : "Identifier",
"location" : [ 29, 17, 29, 20 ],
"name" : "self"
},
"member" : {
"kind" : "Identifier",
"location" : [ 29, 22, 29, 22 ],
"name" : "p"
}
} ],
"value" : {
"kind" : "UnaryExpr",
"location" : [ 29, 26, 29, 35 ],
"operator" : "not",
"operand" : {
"kind" : "MemberExpr",
"location" : [ 29, 30, 29, 35 ],
"object" : {
"kind" : "Identifier",
"location" : [ 29, 30, 29, 33 ],
"name" : "self"
},
"member" : {
"kind" : "Identifier",
"location" : [ 29, 35, 29, 35 ],
"name" : "p"
}
}
}
}, {
"kind" : "AssignStmt",
"location" : [ 30, 17, 30, 25 ],
"targets" : [ {
"kind" : "Identifier",
"location" : [ 30, 17, 30, 17 ],
"name" : "x"
} ],
"value" : {
"kind" : "BinaryExpr",
"location" : [ 30, 21, 30, 25 ],
"left" : {
"kind" : "Identifier",
"location" : [ 30, 21, 30, 21 ],
"name" : "x"
},
"operator" : "+",
"right" : {
"kind" : "IntegerLiteral",
"location" : [ 30, 25, 30, 25 ],
"value" : 1
}
}
} ],
"elseBody" : [ {
"kind" : "IfStmt",
"location" : [ 31, 13, 34, 8 ],
"condition" : {
"kind" : "BinaryExpr",
"location" : [ 31, 18, 31, 36 ],
"left" : {
"kind" : "CallExpr",
"location" : [ 31, 18, 31, 31 ],
"function" : {
"kind" : "Identifier",
"location" : [ 31, 18, 31, 20 ],
"name" : "foo"
},
"args" : [ {
"kind" : "IndexExpr",
"location" : [ 31, 22, 31, 30 ],
"list" : {
"kind" : "StringLiteral",
"location" : [ 31, 22, 31, 27 ],
"value" : "Long"
},
"index" : {
"kind" : "IntegerLiteral",
"location" : [ 31, 29, 31, 29 ],
"value" : 0
}
} ]
},
"operator" : "==",
"right" : {
"kind" : "IntegerLiteral",
"location" : [ 31, 36, 31, 36 ],
"value" : 1
}
},
"thenBody" : [ {
"kind" : "ReturnStmt",
"location" : [ 32, 17, 32, 35 ],
"value" : {
"kind" : "BinaryExpr",
"location" : [ 32, 24, 32, 35 ],
"left" : {
"kind" : "Identifier",
"location" : [ 32, 24, 32, 27 ],
"name" : "self"
},
"operator" : "is",
"right" : {
"kind" : "NoneLiteral",
"location" : [ 32, 32, 32, 35 ]
}
}
} ],
"elseBody" : [ ]
} ]
} ]
}, {
"kind" : "ReturnStmt",
"location" : [ 34, 9, 34, 21 ],
"value" : {
"kind" : "StringLiteral",
"location" : [ 34, 16, 34, 21 ],
"value" : "Nope"
}
} ]
} ]
} ],
"statements" : [ {
"kind" : "ExprStmt",
"location" : [ 36, 1, 36, 23 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 36, 1, 36, 23 ],
"function" : {
"kind" : "Identifier",
"location" : [ 36, 1, 36, 5 ],
"name" : "print"
},
"args" : [ {
"kind" : "MethodCallExpr",
"location" : [ 36, 7, 36, 22 ],
"method" : {
"kind" : "MemberExpr",
"location" : [ 36, 7, 36, 15 ],
"object" : {
"kind" : "CallExpr",
"location" : [ 36, 7, 36, 11 ],
"function" : {
"kind" : "Identifier",
"location" : [ 36, 7, 36, 9 ],
"name" : "bar"
},
"args" : [ ]
},
"member" : {
"kind" : "Identifier",
"location" : [ 36, 13, 36, 15 ],
"name" : "baz"
}
},
"args" : [ {
"kind" : "ListExpr",
"location" : [ 36, 17, 36, 21 ],
"elements" : [ {
"kind" : "IntegerLiteral",
"location" : [ 36, 18, 36, 18 ],
"value" : 1
}, {
"kind" : "IntegerLiteral",
"location" : [ 36, 20, 36, 20 ],
"value" : 2
} ]
} ]
} ]
}
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}
+4
View File
@@ -0,0 +1,4 @@
def foo() -> int:
return 1
foo()
+48
View File
@@ -0,0 +1,48 @@
{
"kind" : "Program",
"location" : [ 1, 1, 4, 6 ],
"declarations" : [ {
"kind" : "FuncDef",
"location" : [ 1, 1, 2, 13 ],
"name" : {
"kind" : "Identifier",
"location" : [ 1, 5, 1, 7 ],
"name" : "foo"
},
"params" : [ ],
"returnType" : {
"kind" : "ClassType",
"location" : [ 1, 14, 1, 16 ],
"className" : "int"
},
"declarations" : [ ],
"statements" : [ {
"kind" : "ReturnStmt",
"location" : [ 2, 5, 2, 12 ],
"value" : {
"kind" : "IntegerLiteral",
"location" : [ 2, 12, 2, 12 ],
"value" : 1
}
} ]
} ],
"statements" : [ {
"kind" : "ExprStmt",
"location" : [ 4, 1, 4, 5 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 4, 1, 4, 5 ],
"function" : {
"kind" : "Identifier",
"location" : [ 4, 1, 4, 3 ],
"name" : "foo"
},
"args" : [ ]
}
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}
+4
View File
@@ -0,0 +1,4 @@
def foo(x:int, y:int) -> bool:
return x > y
foo(1,2)
+92
View File
@@ -0,0 +1,92 @@
{
"kind" : "Program",
"location" : [ 1, 1, 4, 9 ],
"declarations" : [ {
"kind" : "FuncDef",
"location" : [ 1, 1, 2, 17 ],
"name" : {
"kind" : "Identifier",
"location" : [ 1, 5, 1, 7 ],
"name" : "foo"
},
"params" : [ {
"kind" : "TypedVar",
"location" : [ 1, 9, 1, 13 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 1, 9, 1, 9 ],
"name" : "x"
},
"type" : {
"kind" : "ClassType",
"location" : [ 1, 11, 1, 13 ],
"className" : "int"
}
}, {
"kind" : "TypedVar",
"location" : [ 1, 16, 1, 20 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 1, 16, 1, 16 ],
"name" : "y"
},
"type" : {
"kind" : "ClassType",
"location" : [ 1, 18, 1, 20 ],
"className" : "int"
}
} ],
"returnType" : {
"kind" : "ClassType",
"location" : [ 1, 26, 1, 29 ],
"className" : "bool"
},
"declarations" : [ ],
"statements" : [ {
"kind" : "ReturnStmt",
"location" : [ 2, 5, 2, 16 ],
"value" : {
"kind" : "BinaryExpr",
"location" : [ 2, 12, 2, 16 ],
"left" : {
"kind" : "Identifier",
"location" : [ 2, 12, 2, 12 ],
"name" : "x"
},
"operator" : ">",
"right" : {
"kind" : "Identifier",
"location" : [ 2, 16, 2, 16 ],
"name" : "y"
}
}
} ]
} ],
"statements" : [ {
"kind" : "ExprStmt",
"location" : [ 4, 1, 4, 8 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 4, 1, 4, 8 ],
"function" : {
"kind" : "Identifier",
"location" : [ 4, 1, 4, 3 ],
"name" : "foo"
},
"args" : [ {
"kind" : "IntegerLiteral",
"location" : [ 4, 5, 4, 5 ],
"value" : 1
}, {
"kind" : "IntegerLiteral",
"location" : [ 4, 7, 4, 7 ],
"value" : 2
} ]
}
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}
+7
View File
@@ -0,0 +1,7 @@
z:int = 0
def foo(x:int) -> bool:
global z
return x > z
foo(1)
+105
View File
@@ -0,0 +1,105 @@
{
"kind" : "Program",
"location" : [ 1, 1, 7, 7 ],
"declarations" : [ {
"kind" : "VarDef",
"location" : [ 1, 1, 1, 9 ],
"var" : {
"kind" : "TypedVar",
"location" : [ 1, 1, 1, 5 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 1, 1, 1, 1 ],
"name" : "z"
},
"type" : {
"kind" : "ClassType",
"location" : [ 1, 3, 1, 5 ],
"className" : "int"
}
},
"value" : {
"kind" : "IntegerLiteral",
"location" : [ 1, 9, 1, 9 ],
"value" : 0
}
}, {
"kind" : "FuncDef",
"location" : [ 3, 1, 5, 17 ],
"name" : {
"kind" : "Identifier",
"location" : [ 3, 5, 3, 7 ],
"name" : "foo"
},
"params" : [ {
"kind" : "TypedVar",
"location" : [ 3, 9, 3, 13 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 3, 9, 3, 9 ],
"name" : "x"
},
"type" : {
"kind" : "ClassType",
"location" : [ 3, 11, 3, 13 ],
"className" : "int"
}
} ],
"returnType" : {
"kind" : "ClassType",
"location" : [ 3, 19, 3, 22 ],
"className" : "bool"
},
"declarations" : [ {
"kind" : "GlobalDecl",
"location" : [ 4, 5, 4, 12 ],
"variable" : {
"kind" : "Identifier",
"location" : [ 4, 12, 4, 12 ],
"name" : "z"
}
} ],
"statements" : [ {
"kind" : "ReturnStmt",
"location" : [ 5, 5, 5, 16 ],
"value" : {
"kind" : "BinaryExpr",
"location" : [ 5, 12, 5, 16 ],
"left" : {
"kind" : "Identifier",
"location" : [ 5, 12, 5, 12 ],
"name" : "x"
},
"operator" : ">",
"right" : {
"kind" : "Identifier",
"location" : [ 5, 16, 5, 16 ],
"name" : "z"
}
}
} ]
} ],
"statements" : [ {
"kind" : "ExprStmt",
"location" : [ 7, 1, 7, 6 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 7, 1, 7, 6 ],
"function" : {
"kind" : "Identifier",
"location" : [ 7, 1, 7, 3 ],
"name" : "foo"
},
"args" : [ {
"kind" : "IntegerLiteral",
"location" : [ 7, 5, 7, 5 ],
"value" : 1
} ]
}
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}
+10
View File
@@ -0,0 +1,10 @@
def foo(x:int) -> bool:
a:int = 0
b:int = 1
def bar(y: int) -> int:
a:int = 2
return y
return bar(x) > a
foo(1)
+187
View File
@@ -0,0 +1,187 @@
{
"kind" : "Program",
"location" : [ 2, 1, 10, 7 ],
"declarations" : [ {
"kind" : "FuncDef",
"location" : [ 2, 1, 8, 22 ],
"name" : {
"kind" : "Identifier",
"location" : [ 2, 5, 2, 7 ],
"name" : "foo"
},
"params" : [ {
"kind" : "TypedVar",
"location" : [ 2, 9, 2, 13 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 2, 9, 2, 9 ],
"name" : "x"
},
"type" : {
"kind" : "ClassType",
"location" : [ 2, 11, 2, 13 ],
"className" : "int"
}
} ],
"returnType" : {
"kind" : "ClassType",
"location" : [ 2, 19, 2, 22 ],
"className" : "bool"
},
"declarations" : [ {
"kind" : "VarDef",
"location" : [ 3, 5, 3, 13 ],
"var" : {
"kind" : "TypedVar",
"location" : [ 3, 5, 3, 9 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 3, 5, 3, 5 ],
"name" : "a"
},
"type" : {
"kind" : "ClassType",
"location" : [ 3, 7, 3, 9 ],
"className" : "int"
}
},
"value" : {
"kind" : "IntegerLiteral",
"location" : [ 3, 13, 3, 13 ],
"value" : 0
}
}, {
"kind" : "VarDef",
"location" : [ 4, 5, 4, 13 ],
"var" : {
"kind" : "TypedVar",
"location" : [ 4, 5, 4, 9 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 4, 5, 4, 5 ],
"name" : "b"
},
"type" : {
"kind" : "ClassType",
"location" : [ 4, 7, 4, 9 ],
"className" : "int"
}
},
"value" : {
"kind" : "IntegerLiteral",
"location" : [ 4, 13, 4, 13 ],
"value" : 1
}
}, {
"kind" : "FuncDef",
"location" : [ 5, 5, 7, 17 ],
"name" : {
"kind" : "Identifier",
"location" : [ 5, 9, 5, 11 ],
"name" : "bar"
},
"params" : [ {
"kind" : "TypedVar",
"location" : [ 5, 13, 5, 18 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 5, 13, 5, 13 ],
"name" : "y"
},
"type" : {
"kind" : "ClassType",
"location" : [ 5, 16, 5, 18 ],
"className" : "int"
}
} ],
"returnType" : {
"kind" : "ClassType",
"location" : [ 5, 24, 5, 26 ],
"className" : "int"
},
"declarations" : [ {
"kind" : "VarDef",
"location" : [ 6, 9, 6, 17 ],
"var" : {
"kind" : "TypedVar",
"location" : [ 6, 9, 6, 13 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 6, 9, 6, 9 ],
"name" : "a"
},
"type" : {
"kind" : "ClassType",
"location" : [ 6, 11, 6, 13 ],
"className" : "int"
}
},
"value" : {
"kind" : "IntegerLiteral",
"location" : [ 6, 17, 6, 17 ],
"value" : 2
}
} ],
"statements" : [ {
"kind" : "ReturnStmt",
"location" : [ 7, 9, 7, 16 ],
"value" : {
"kind" : "Identifier",
"location" : [ 7, 16, 7, 16 ],
"name" : "y"
}
} ]
} ],
"statements" : [ {
"kind" : "ReturnStmt",
"location" : [ 8, 5, 8, 21 ],
"value" : {
"kind" : "BinaryExpr",
"location" : [ 8, 12, 8, 21 ],
"left" : {
"kind" : "CallExpr",
"location" : [ 8, 12, 8, 17 ],
"function" : {
"kind" : "Identifier",
"location" : [ 8, 12, 8, 14 ],
"name" : "bar"
},
"args" : [ {
"kind" : "Identifier",
"location" : [ 8, 16, 8, 16 ],
"name" : "x"
} ]
},
"operator" : ">",
"right" : {
"kind" : "Identifier",
"location" : [ 8, 21, 8, 21 ],
"name" : "a"
}
}
} ]
} ],
"statements" : [ {
"kind" : "ExprStmt",
"location" : [ 10, 1, 10, 6 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 10, 1, 10, 6 ],
"function" : {
"kind" : "Identifier",
"location" : [ 10, 1, 10, 3 ],
"name" : "foo"
},
"args" : [ {
"kind" : "IntegerLiteral",
"location" : [ 10, 5, 10, 5 ],
"value" : 1
} ]
}
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}
+11
View File
@@ -0,0 +1,11 @@
def foo(x:int) -> bool:
a:int = 0
b:int = 1
def bar(y: int) -> int:
nonlocal a
a = 2
return y
return bar(x) > a
foo(1)
+186
View File
@@ -0,0 +1,186 @@
{
"kind" : "Program",
"location" : [ 2, 1, 11, 7 ],
"declarations" : [ {
"kind" : "FuncDef",
"location" : [ 2, 1, 9, 22 ],
"name" : {
"kind" : "Identifier",
"location" : [ 2, 5, 2, 7 ],
"name" : "foo"
},
"params" : [ {
"kind" : "TypedVar",
"location" : [ 2, 9, 2, 13 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 2, 9, 2, 9 ],
"name" : "x"
},
"type" : {
"kind" : "ClassType",
"location" : [ 2, 11, 2, 13 ],
"className" : "int"
}
} ],
"returnType" : {
"kind" : "ClassType",
"location" : [ 2, 19, 2, 22 ],
"className" : "bool"
},
"declarations" : [ {
"kind" : "VarDef",
"location" : [ 3, 5, 3, 13 ],
"var" : {
"kind" : "TypedVar",
"location" : [ 3, 5, 3, 9 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 3, 5, 3, 5 ],
"name" : "a"
},
"type" : {
"kind" : "ClassType",
"location" : [ 3, 7, 3, 9 ],
"className" : "int"
}
},
"value" : {
"kind" : "IntegerLiteral",
"location" : [ 3, 13, 3, 13 ],
"value" : 0
}
}, {
"kind" : "VarDef",
"location" : [ 4, 5, 4, 13 ],
"var" : {
"kind" : "TypedVar",
"location" : [ 4, 5, 4, 9 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 4, 5, 4, 5 ],
"name" : "b"
},
"type" : {
"kind" : "ClassType",
"location" : [ 4, 7, 4, 9 ],
"className" : "int"
}
},
"value" : {
"kind" : "IntegerLiteral",
"location" : [ 4, 13, 4, 13 ],
"value" : 1
}
}, {
"kind" : "FuncDef",
"location" : [ 5, 5, 8, 17 ],
"name" : {
"kind" : "Identifier",
"location" : [ 5, 9, 5, 11 ],
"name" : "bar"
},
"params" : [ {
"kind" : "TypedVar",
"location" : [ 5, 13, 5, 18 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 5, 13, 5, 13 ],
"name" : "y"
},
"type" : {
"kind" : "ClassType",
"location" : [ 5, 16, 5, 18 ],
"className" : "int"
}
} ],
"returnType" : {
"kind" : "ClassType",
"location" : [ 5, 24, 5, 26 ],
"className" : "int"
},
"declarations" : [ {
"kind" : "NonLocalDecl",
"location" : [ 6, 9, 6, 18 ],
"variable" : {
"kind" : "Identifier",
"location" : [ 6, 18, 6, 18 ],
"name" : "a"
}
} ],
"statements" : [ {
"kind" : "AssignStmt",
"location" : [ 7, 9, 7, 13 ],
"targets" : [ {
"kind" : "Identifier",
"location" : [ 7, 9, 7, 9 ],
"name" : "a"
} ],
"value" : {
"kind" : "IntegerLiteral",
"location" : [ 7, 13, 7, 13 ],
"value" : 2
}
}, {
"kind" : "ReturnStmt",
"location" : [ 8, 9, 8, 16 ],
"value" : {
"kind" : "Identifier",
"location" : [ 8, 16, 8, 16 ],
"name" : "y"
}
} ]
} ],
"statements" : [ {
"kind" : "ReturnStmt",
"location" : [ 9, 5, 9, 21 ],
"value" : {
"kind" : "BinaryExpr",
"location" : [ 9, 12, 9, 21 ],
"left" : {
"kind" : "CallExpr",
"location" : [ 9, 12, 9, 17 ],
"function" : {
"kind" : "Identifier",
"location" : [ 9, 12, 9, 14 ],
"name" : "bar"
},
"args" : [ {
"kind" : "Identifier",
"location" : [ 9, 16, 9, 16 ],
"name" : "x"
} ]
},
"operator" : ">",
"right" : {
"kind" : "Identifier",
"location" : [ 9, 21, 9, 21 ],
"name" : "a"
}
}
} ]
} ],
"statements" : [ {
"kind" : "ExprStmt",
"location" : [ 11, 1, 11, 6 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 11, 1, 11, 6 ],
"function" : {
"kind" : "Identifier",
"location" : [ 11, 1, 11, 3 ],
"name" : "foo"
},
"args" : [ {
"kind" : "IntegerLiteral",
"location" : [ 11, 5, 11, 5 ],
"value" : 1
} ]
}
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}
+1
View File
@@ -0,0 +1 @@
3 if 1 > 2 else 4
+43
View File
@@ -0,0 +1,43 @@
{
"kind" : "Program",
"location" : [ 1, 1, 1, 18 ],
"declarations" : [ ],
"statements" : [ {
"kind" : "ExprStmt",
"location" : [ 1, 1, 1, 17 ],
"expr" : {
"kind" : "IfExpr",
"location" : [ 1, 1, 1, 17 ],
"condition" : {
"kind" : "BinaryExpr",
"location" : [ 1, 6, 1, 10 ],
"left" : {
"kind" : "IntegerLiteral",
"location" : [ 1, 6, 1, 6 ],
"value" : 1
},
"operator" : ">",
"right" : {
"kind" : "IntegerLiteral",
"location" : [ 1, 10, 1, 10 ],
"value" : 2
}
},
"thenExpr" : {
"kind" : "IntegerLiteral",
"location" : [ 1, 1, 1, 1 ],
"value" : 3
},
"elseExpr" : {
"kind" : "IntegerLiteral",
"location" : [ 1, 17, 1, 17 ],
"value" : 4
}
}
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}
+1
View File
@@ -0,0 +1 @@
3 if 1 > 2 else 4 if 1 < 0 else 5
+67
View File
@@ -0,0 +1,67 @@
{
"kind" : "Program",
"location" : [ 1, 1, 1, 34 ],
"declarations" : [ ],
"statements" : [ {
"kind" : "ExprStmt",
"location" : [ 1, 1, 1, 33 ],
"expr" : {
"kind" : "IfExpr",
"location" : [ 1, 1, 1, 33 ],
"condition" : {
"kind" : "BinaryExpr",
"location" : [ 1, 6, 1, 10 ],
"left" : {
"kind" : "IntegerLiteral",
"location" : [ 1, 6, 1, 6 ],
"value" : 1
},
"operator" : ">",
"right" : {
"kind" : "IntegerLiteral",
"location" : [ 1, 10, 1, 10 ],
"value" : 2
}
},
"thenExpr" : {
"kind" : "IntegerLiteral",
"location" : [ 1, 1, 1, 1 ],
"value" : 3
},
"elseExpr" : {
"kind" : "IfExpr",
"location" : [ 1, 17, 1, 33 ],
"condition" : {
"kind" : "BinaryExpr",
"location" : [ 1, 22, 1, 26 ],
"left" : {
"kind" : "IntegerLiteral",
"location" : [ 1, 22, 1, 22 ],
"value" : 1
},
"operator" : "<",
"right" : {
"kind" : "IntegerLiteral",
"location" : [ 1, 26, 1, 26 ],
"value" : 0
}
},
"thenExpr" : {
"kind" : "IntegerLiteral",
"location" : [ 1, 17, 1, 17 ],
"value" : 4
},
"elseExpr" : {
"kind" : "IntegerLiteral",
"location" : [ 1, 33, 1, 33 ],
"value" : 5
}
}
}
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}
+1
View File
@@ -0,0 +1 @@
a + b[i][j]
+47
View File
@@ -0,0 +1,47 @@
{
"kind" : "Program",
"location" : [ 1, 1, 1, 12 ],
"declarations" : [ ],
"statements" : [ {
"kind" : "ExprStmt",
"location" : [ 1, 1, 1, 11 ],
"expr" : {
"kind" : "BinaryExpr",
"location" : [ 1, 1, 1, 11 ],
"left" : {
"kind" : "Identifier",
"location" : [ 1, 1, 1, 1 ],
"name" : "a"
},
"operator" : "+",
"right" : {
"kind" : "IndexExpr",
"location" : [ 1, 5, 1, 11 ],
"list" : {
"kind" : "IndexExpr",
"location" : [ 1, 5, 1, 8 ],
"list" : {
"kind" : "Identifier",
"location" : [ 1, 5, 1, 5 ],
"name" : "b"
},
"index" : {
"kind" : "Identifier",
"location" : [ 1, 7, 1, 7 ],
"name" : "i"
}
},
"index" : {
"kind" : "Identifier",
"location" : [ 1, 10, 1, 10 ],
"name" : "j"
}
}
}
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}
+1
View File
@@ -0,0 +1 @@
1 + 2 + 3
+39
View File
@@ -0,0 +1,39 @@
{
"kind" : "Program",
"location" : [ 1, 1, 1, 10 ],
"declarations" : [ ],
"statements" : [ {
"kind" : "ExprStmt",
"location" : [ 1, 1, 1, 9 ],
"expr" : {
"kind" : "BinaryExpr",
"location" : [ 1, 1, 1, 9 ],
"left" : {
"kind" : "BinaryExpr",
"location" : [ 1, 1, 1, 5 ],
"left" : {
"kind" : "IntegerLiteral",
"location" : [ 1, 1, 1, 1 ],
"value" : 1
},
"operator" : "+",
"right" : {
"kind" : "IntegerLiteral",
"location" : [ 1, 5, 1, 5 ],
"value" : 2
}
},
"operator" : "+",
"right" : {
"kind" : "IntegerLiteral",
"location" : [ 1, 9, 1, 9 ],
"value" : 3
}
}
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}
+1
View File
@@ -0,0 +1 @@
-1
+24
View File
@@ -0,0 +1,24 @@
{
"kind" : "Program",
"location" : [ 1, 1, 1, 3 ],
"declarations" : [ ],
"statements" : [ {
"kind" : "ExprStmt",
"location" : [ 1, 1, 1, 2 ],
"expr" : {
"kind" : "UnaryExpr",
"location" : [ 1, 1, 1, 2 ],
"operator" : "-",
"operand" : {
"kind" : "IntegerLiteral",
"location" : [ 1, 2, 1, 2 ],
"value" : 1
}
}
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}
+5
View File
@@ -0,0 +1,5 @@
x:int = 1
x = 2
print(x)
+63
View File
@@ -0,0 +1,63 @@
{
"kind" : "Program",
"location" : [ 1, 1, 5, 9 ],
"declarations" : [ {
"kind" : "VarDef",
"location" : [ 1, 1, 1, 9 ],
"var" : {
"kind" : "TypedVar",
"location" : [ 1, 1, 1, 5 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 1, 1, 1, 1 ],
"name" : "x"
},
"type" : {
"kind" : "ClassType",
"location" : [ 1, 3, 1, 5 ],
"className" : "int"
}
},
"value" : {
"kind" : "IntegerLiteral",
"location" : [ 1, 9, 1, 9 ],
"value" : 1
}
} ],
"statements" : [ {
"kind" : "AssignStmt",
"location" : [ 3, 1, 3, 5 ],
"targets" : [ {
"kind" : "Identifier",
"location" : [ 3, 1, 3, 1 ],
"name" : "x"
} ],
"value" : {
"kind" : "IntegerLiteral",
"location" : [ 3, 5, 3, 5 ],
"value" : 2
}
}, {
"kind" : "ExprStmt",
"location" : [ 5, 1, 5, 8 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 5, 1, 5, 8 ],
"function" : {
"kind" : "Identifier",
"location" : [ 5, 1, 5, 5 ],
"name" : "print"
},
"args" : [ {
"kind" : "Identifier",
"location" : [ 5, 7, 5, 7 ],
"name" : "x"
} ]
}
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}
+7
View File
@@ -0,0 +1,7 @@
True
False
1
None
"This is a string"
[1, 2, 3]
+70
View File
@@ -0,0 +1,70 @@
{
"kind" : "Program",
"location" : [ 1, 1, 6, 10 ],
"declarations" : [ ],
"statements" : [ {
"kind" : "ExprStmt",
"location" : [ 1, 1, 1, 4 ],
"expr" : {
"kind" : "BooleanLiteral",
"location" : [ 1, 1, 1, 4 ],
"value" : true
}
}, {
"kind" : "ExprStmt",
"location" : [ 2, 1, 2, 5 ],
"expr" : {
"kind" : "BooleanLiteral",
"location" : [ 2, 1, 2, 5 ],
"value" : false
}
}, {
"kind" : "ExprStmt",
"location" : [ 3, 1, 3, 1 ],
"expr" : {
"kind" : "IntegerLiteral",
"location" : [ 3, 1, 3, 1 ],
"value" : 1
}
}, {
"kind" : "ExprStmt",
"location" : [ 4, 1, 4, 4 ],
"expr" : {
"kind" : "NoneLiteral",
"location" : [ 4, 1, 4, 4 ]
}
}, {
"kind" : "ExprStmt",
"location" : [ 5, 1, 5, 18 ],
"expr" : {
"kind" : "StringLiteral",
"location" : [ 5, 1, 5, 18 ],
"value" : "This is a string"
}
}, {
"kind" : "ExprStmt",
"location" : [ 6, 1, 6, 9 ],
"expr" : {
"kind" : "ListExpr",
"location" : [ 6, 1, 6, 9 ],
"elements" : [ {
"kind" : "IntegerLiteral",
"location" : [ 6, 2, 6, 2 ],
"value" : 1
}, {
"kind" : "IntegerLiteral",
"location" : [ 6, 5, 6, 5 ],
"value" : 2
}, {
"kind" : "IntegerLiteral",
"location" : [ 6, 8, 6, 8 ],
"value" : 3
} ]
}
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}
+1
View File
@@ -0,0 +1 @@
print(1)
+28
View File
@@ -0,0 +1,28 @@
{
"kind" : "Program",
"location" : [ 1, 1, 1, 9 ],
"declarations" : [ ],
"statements" : [ {
"kind" : "ExprStmt",
"location" : [ 1, 1, 1, 8 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 1, 1, 1, 8 ],
"function" : {
"kind" : "Identifier",
"location" : [ 1, 1, 1, 5 ],
"name" : "print"
},
"args" : [ {
"kind" : "IntegerLiteral",
"location" : [ 1, 7, 1, 7 ],
"value" : 1
} ]
}
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}
+4
View File
@@ -0,0 +1,4 @@
x:int = 0
for x in [1, 2, 3]:
print(x)
+76
View File
@@ -0,0 +1,76 @@
{
"kind" : "Program",
"location" : [ 1, 1, 5, 1 ],
"declarations" : [ {
"kind" : "VarDef",
"location" : [ 1, 1, 1, 9 ],
"var" : {
"kind" : "TypedVar",
"location" : [ 1, 1, 1, 5 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 1, 1, 1, 1 ],
"name" : "x"
},
"type" : {
"kind" : "ClassType",
"location" : [ 1, 3, 1, 5 ],
"className" : "int"
}
},
"value" : {
"kind" : "IntegerLiteral",
"location" : [ 1, 9, 1, 9 ],
"value" : 0
}
} ],
"statements" : [ {
"kind" : "ForStmt",
"location" : [ 2, 1, 5, 1 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 2, 5, 2, 5 ],
"name" : "x"
},
"iterable" : {
"kind" : "ListExpr",
"location" : [ 2, 10, 2, 18 ],
"elements" : [ {
"kind" : "IntegerLiteral",
"location" : [ 2, 11, 2, 11 ],
"value" : 1
}, {
"kind" : "IntegerLiteral",
"location" : [ 2, 14, 2, 14 ],
"value" : 2
}, {
"kind" : "IntegerLiteral",
"location" : [ 2, 17, 2, 17 ],
"value" : 3
} ]
},
"body" : [ {
"kind" : "ExprStmt",
"location" : [ 3, 5, 3, 12 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 3, 5, 3, 12 ],
"function" : {
"kind" : "Identifier",
"location" : [ 3, 5, 3, 9 ],
"name" : "print"
},
"args" : [ {
"kind" : "Identifier",
"location" : [ 3, 11, 3, 11 ],
"name" : "x"
} ]
}
} ]
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}
+3
View File
@@ -0,0 +1,3 @@
if True:
False
+29
View File
@@ -0,0 +1,29 @@
{
"kind" : "Program",
"location" : [ 1, 1, 4, 1 ],
"declarations" : [ ],
"statements" : [ {
"kind" : "IfStmt",
"location" : [ 1, 1, 4, 1 ],
"condition" : {
"kind" : "BooleanLiteral",
"location" : [ 1, 4, 1, 7 ],
"value" : true
},
"thenBody" : [ {
"kind" : "ExprStmt",
"location" : [ 2, 5, 2, 9 ],
"expr" : {
"kind" : "BooleanLiteral",
"location" : [ 2, 5, 2, 9 ],
"value" : false
}
} ],
"elseBody" : [ ]
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}
+6
View File
@@ -0,0 +1,6 @@
if 1 > 2:
print(1)
elif 3 == 4:
print(2)
elif True:
print(3)
+112
View File
@@ -0,0 +1,112 @@
{
"kind" : "Program",
"location" : [ 1, 1, 7, 1 ],
"declarations" : [ ],
"statements" : [ {
"kind" : "IfStmt",
"location" : [ 1, 1, 7, 1 ],
"condition" : {
"kind" : "BinaryExpr",
"location" : [ 1, 4, 1, 8 ],
"left" : {
"kind" : "IntegerLiteral",
"location" : [ 1, 4, 1, 4 ],
"value" : 1
},
"operator" : ">",
"right" : {
"kind" : "IntegerLiteral",
"location" : [ 1, 8, 1, 8 ],
"value" : 2
}
},
"thenBody" : [ {
"kind" : "ExprStmt",
"location" : [ 2, 5, 2, 12 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 2, 5, 2, 12 ],
"function" : {
"kind" : "Identifier",
"location" : [ 2, 5, 2, 9 ],
"name" : "print"
},
"args" : [ {
"kind" : "IntegerLiteral",
"location" : [ 2, 11, 2, 11 ],
"value" : 1
} ]
}
} ],
"elseBody" : [ {
"kind" : "IfStmt",
"location" : [ 3, 1, 7, 1 ],
"condition" : {
"kind" : "BinaryExpr",
"location" : [ 3, 6, 3, 11 ],
"left" : {
"kind" : "IntegerLiteral",
"location" : [ 3, 6, 3, 6 ],
"value" : 3
},
"operator" : "==",
"right" : {
"kind" : "IntegerLiteral",
"location" : [ 3, 11, 3, 11 ],
"value" : 4
}
},
"thenBody" : [ {
"kind" : "ExprStmt",
"location" : [ 4, 5, 4, 12 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 4, 5, 4, 12 ],
"function" : {
"kind" : "Identifier",
"location" : [ 4, 5, 4, 9 ],
"name" : "print"
},
"args" : [ {
"kind" : "IntegerLiteral",
"location" : [ 4, 11, 4, 11 ],
"value" : 2
} ]
}
} ],
"elseBody" : [ {
"kind" : "IfStmt",
"location" : [ 5, 1, 7, 1 ],
"condition" : {
"kind" : "BooleanLiteral",
"location" : [ 5, 6, 5, 9 ],
"value" : true
},
"thenBody" : [ {
"kind" : "ExprStmt",
"location" : [ 6, 5, 6, 12 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 6, 5, 6, 12 ],
"function" : {
"kind" : "Identifier",
"location" : [ 6, 5, 6, 9 ],
"name" : "print"
},
"args" : [ {
"kind" : "IntegerLiteral",
"location" : [ 6, 11, 6, 11 ],
"value" : 3
} ]
}
} ],
"elseBody" : [ ]
} ]
} ]
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}
+8
View File
@@ -0,0 +1,8 @@
if 1 > 2:
print(1)
elif 3 == 4:
print(2)
elif True:
print(3)
else:
print(4)
+129
View File
@@ -0,0 +1,129 @@
{
"kind" : "Program",
"location" : [ 1, 1, 9, 1 ],
"declarations" : [ ],
"statements" : [ {
"kind" : "IfStmt",
"location" : [ 1, 1, 9, 1 ],
"condition" : {
"kind" : "BinaryExpr",
"location" : [ 1, 4, 1, 8 ],
"left" : {
"kind" : "IntegerLiteral",
"location" : [ 1, 4, 1, 4 ],
"value" : 1
},
"operator" : ">",
"right" : {
"kind" : "IntegerLiteral",
"location" : [ 1, 8, 1, 8 ],
"value" : 2
}
},
"thenBody" : [ {
"kind" : "ExprStmt",
"location" : [ 2, 5, 2, 12 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 2, 5, 2, 12 ],
"function" : {
"kind" : "Identifier",
"location" : [ 2, 5, 2, 9 ],
"name" : "print"
},
"args" : [ {
"kind" : "IntegerLiteral",
"location" : [ 2, 11, 2, 11 ],
"value" : 1
} ]
}
} ],
"elseBody" : [ {
"kind" : "IfStmt",
"location" : [ 3, 1, 9, 1 ],
"condition" : {
"kind" : "BinaryExpr",
"location" : [ 3, 6, 3, 11 ],
"left" : {
"kind" : "IntegerLiteral",
"location" : [ 3, 6, 3, 6 ],
"value" : 3
},
"operator" : "==",
"right" : {
"kind" : "IntegerLiteral",
"location" : [ 3, 11, 3, 11 ],
"value" : 4
}
},
"thenBody" : [ {
"kind" : "ExprStmt",
"location" : [ 4, 5, 4, 12 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 4, 5, 4, 12 ],
"function" : {
"kind" : "Identifier",
"location" : [ 4, 5, 4, 9 ],
"name" : "print"
},
"args" : [ {
"kind" : "IntegerLiteral",
"location" : [ 4, 11, 4, 11 ],
"value" : 2
} ]
}
} ],
"elseBody" : [ {
"kind" : "IfStmt",
"location" : [ 5, 1, 9, 1 ],
"condition" : {
"kind" : "BooleanLiteral",
"location" : [ 5, 6, 5, 9 ],
"value" : true
},
"thenBody" : [ {
"kind" : "ExprStmt",
"location" : [ 6, 5, 6, 12 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 6, 5, 6, 12 ],
"function" : {
"kind" : "Identifier",
"location" : [ 6, 5, 6, 9 ],
"name" : "print"
},
"args" : [ {
"kind" : "IntegerLiteral",
"location" : [ 6, 11, 6, 11 ],
"value" : 3
} ]
}
} ],
"elseBody" : [ {
"kind" : "ExprStmt",
"location" : [ 8, 5, 8, 12 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 8, 5, 8, 12 ],
"function" : {
"kind" : "Identifier",
"location" : [ 8, 5, 8, 9 ],
"name" : "print"
},
"args" : [ {
"kind" : "IntegerLiteral",
"location" : [ 8, 11, 8, 11 ],
"value" : 4
} ]
}
} ]
} ]
} ]
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}
+5
View File
@@ -0,0 +1,5 @@
if True:
False
else:
True
+37
View File
@@ -0,0 +1,37 @@
{
"kind" : "Program",
"location" : [ 1, 1, 6, 1 ],
"declarations" : [ ],
"statements" : [ {
"kind" : "IfStmt",
"location" : [ 1, 1, 6, 1 ],
"condition" : {
"kind" : "BooleanLiteral",
"location" : [ 1, 4, 1, 7 ],
"value" : true
},
"thenBody" : [ {
"kind" : "ExprStmt",
"location" : [ 2, 5, 2, 9 ],
"expr" : {
"kind" : "BooleanLiteral",
"location" : [ 2, 5, 2, 9 ],
"value" : false
}
} ],
"elseBody" : [ {
"kind" : "ExprStmt",
"location" : [ 4, 5, 4, 8 ],
"expr" : {
"kind" : "BooleanLiteral",
"location" : [ 4, 5, 4, 8 ],
"value" : true
}
} ]
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}
+4
View File
@@ -0,0 +1,4 @@
x:int = None
x = [1, 2, 3]
x[0] = x[1]
+88
View File
@@ -0,0 +1,88 @@
{
"kind" : "Program",
"location" : [ 1, 1, 4, 12 ],
"declarations" : [ {
"kind" : "VarDef",
"location" : [ 1, 1, 1, 12 ],
"var" : {
"kind" : "TypedVar",
"location" : [ 1, 1, 1, 5 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 1, 1, 1, 1 ],
"name" : "x"
},
"type" : {
"kind" : "ClassType",
"location" : [ 1, 3, 1, 5 ],
"className" : "int"
}
},
"value" : {
"kind" : "NoneLiteral",
"location" : [ 1, 9, 1, 12 ]
}
} ],
"statements" : [ {
"kind" : "AssignStmt",
"location" : [ 3, 1, 3, 13 ],
"targets" : [ {
"kind" : "Identifier",
"location" : [ 3, 1, 3, 1 ],
"name" : "x"
} ],
"value" : {
"kind" : "ListExpr",
"location" : [ 3, 5, 3, 13 ],
"elements" : [ {
"kind" : "IntegerLiteral",
"location" : [ 3, 6, 3, 6 ],
"value" : 1
}, {
"kind" : "IntegerLiteral",
"location" : [ 3, 9, 3, 9 ],
"value" : 2
}, {
"kind" : "IntegerLiteral",
"location" : [ 3, 12, 3, 12 ],
"value" : 3
} ]
}
}, {
"kind" : "AssignStmt",
"location" : [ 4, 1, 4, 11 ],
"targets" : [ {
"kind" : "IndexExpr",
"location" : [ 4, 1, 4, 4 ],
"list" : {
"kind" : "Identifier",
"location" : [ 4, 1, 4, 1 ],
"name" : "x"
},
"index" : {
"kind" : "IntegerLiteral",
"location" : [ 4, 3, 4, 3 ],
"value" : 0
}
} ],
"value" : {
"kind" : "IndexExpr",
"location" : [ 4, 8, 4, 11 ],
"list" : {
"kind" : "Identifier",
"location" : [ 4, 8, 4, 8 ],
"name" : "x"
},
"index" : {
"kind" : "IntegerLiteral",
"location" : [ 4, 10, 4, 10 ],
"value" : 1
}
}
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}
+3
View File
@@ -0,0 +1,3 @@
while True:
pass
+20
View File
@@ -0,0 +1,20 @@
{
"kind" : "Program",
"location" : [ 1, 1, 4, 1 ],
"declarations" : [ ],
"statements" : [ {
"kind" : "WhileStmt",
"location" : [ 1, 1, 4, 1 ],
"condition" : {
"kind" : "BooleanLiteral",
"location" : [ 1, 7, 1, 10 ],
"value" : true
},
"body" : [ ]
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}