master^2
ldXiao 4 years ago
parent b745aab547
commit 4d80343a57

@ -0,0 +1,24 @@
# Tests for PA3: ChocoPy Code Generation
Clone a student repository:
```
TEAM="team"
git clone --branch=pa3final \
https://github.com/nyu-compiler-construction/pa3-chocopy-code-generation-${TEAM}
```
Build it:
```
cd pa3-chocopy-code-generation-${TEAM}
mvn clean package
```
Clone the tests _into_ the student repository:
```
git clone https://github.com/nyu-compiler-construction/pa3-tests
```
Run the tests:
```
./pa3-tests/run-tests.sh
```

@ -0,0 +1,25 @@
# Compute x**y
def exp(x: int, y: int) -> int:
a: int = 0
def f(i: int) -> int:
nonlocal a
def geta() -> int:
return a
if i <= 0:
return geta()
else:
a = a * x
return f(i-1)
a = 1
return f(y)
# Input parameter
n:int = 42
# Run [0, n]
i:int = 0
# Crunch
while i <= n:
print(exp(2, i % 31))
i = i + 1

@ -0,0 +1,562 @@
{
"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 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"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 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"name" : "a"
}
} ]
} ],
"statements" : [ {
"kind" : "IfStmt",
"location" : [ 8, 3, 13, 1 ],
"condition" : {
"kind" : "BinaryExpr",
"location" : [ 8, 6, 8, 11 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "bool"
},
"left" : {
"kind" : "Identifier",
"location" : [ 8, 6, 8, 6 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"name" : "i"
},
"operator" : "<=",
"right" : {
"kind" : "IntegerLiteral",
"location" : [ 8, 11, 8, 11 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 0
}
},
"thenBody" : [ {
"kind" : "ReturnStmt",
"location" : [ 9, 4, 9, 16 ],
"value" : {
"kind" : "CallExpr",
"location" : [ 9, 11, 9, 16 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"function" : {
"kind" : "Identifier",
"location" : [ 9, 11, 9, 14 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "geta"
},
"args" : [ ]
}
} ],
"elseBody" : [ {
"kind" : "AssignStmt",
"location" : [ 11, 4, 11, 12 ],
"targets" : [ {
"kind" : "Identifier",
"location" : [ 11, 4, 11, 4 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"name" : "a"
} ],
"value" : {
"kind" : "BinaryExpr",
"location" : [ 11, 8, 11, 12 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"left" : {
"kind" : "Identifier",
"location" : [ 11, 8, 11, 8 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"name" : "a"
},
"operator" : "*",
"right" : {
"kind" : "Identifier",
"location" : [ 11, 12, 11, 12 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"name" : "x"
}
}
}, {
"kind" : "ReturnStmt",
"location" : [ 12, 4, 12, 16 ],
"value" : {
"kind" : "CallExpr",
"location" : [ 12, 11, 12, 16 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"function" : {
"kind" : "Identifier",
"location" : [ 12, 11, 12, 11 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "int"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "f"
},
"args" : [ {
"kind" : "BinaryExpr",
"location" : [ 12, 13, 12, 15 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"left" : {
"kind" : "Identifier",
"location" : [ 12, 13, 12, 13 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"name" : "i"
},
"operator" : "-",
"right" : {
"kind" : "IntegerLiteral",
"location" : [ 12, 15, 12, 15 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 1
}
} ]
}
} ]
} ]
} ],
"statements" : [ {
"kind" : "AssignStmt",
"location" : [ 13, 2, 13, 6 ],
"targets" : [ {
"kind" : "Identifier",
"location" : [ 13, 2, 13, 2 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"name" : "a"
} ],
"value" : {
"kind" : "IntegerLiteral",
"location" : [ 13, 6, 13, 6 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 1
}
}, {
"kind" : "ReturnStmt",
"location" : [ 14, 2, 14, 12 ],
"value" : {
"kind" : "CallExpr",
"location" : [ 14, 9, 14, 12 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"function" : {
"kind" : "Identifier",
"location" : [ 14, 9, 14, 9 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "int"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "f"
},
"args" : [ {
"kind" : "Identifier",
"location" : [ 14, 11, 14, 11 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"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 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"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 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 0
}
} ],
"statements" : [ {
"kind" : "WhileStmt",
"location" : [ 23, 1, 26, 1 ],
"condition" : {
"kind" : "BinaryExpr",
"location" : [ 23, 7, 23, 12 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "bool"
},
"left" : {
"kind" : "Identifier",
"location" : [ 23, 7, 23, 7 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"name" : "i"
},
"operator" : "<=",
"right" : {
"kind" : "Identifier",
"location" : [ 23, 12, 23, 12 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"name" : "n"
}
},
"body" : [ {
"kind" : "ExprStmt",
"location" : [ 24, 2, 24, 22 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 24, 2, 24, 22 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
},
"function" : {
"kind" : "Identifier",
"location" : [ 24, 2, 24, 6 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
},
"name" : "print"
},
"args" : [ {
"kind" : "CallExpr",
"location" : [ 24, 8, 24, 21 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"function" : {
"kind" : "Identifier",
"location" : [ 24, 8, 24, 10 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "int"
}, {
"kind" : "ClassValueType",
"className" : "int"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "exp"
},
"args" : [ {
"kind" : "IntegerLiteral",
"location" : [ 24, 12, 24, 12 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 2
}, {
"kind" : "BinaryExpr",
"location" : [ 24, 15, 24, 20 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"left" : {
"kind" : "Identifier",
"location" : [ 24, 15, 24, 15 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"name" : "i"
},
"operator" : "%",
"right" : {
"kind" : "IntegerLiteral",
"location" : [ 24, 19, 24, 20 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 31
}
} ]
} ]
}
}, {
"kind" : "AssignStmt",
"location" : [ 25, 2, 25, 10 ],
"targets" : [ {
"kind" : "Identifier",
"location" : [ 25, 2, 25, 2 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"name" : "i"
} ],
"value" : {
"kind" : "BinaryExpr",
"location" : [ 25, 6, 25, 10 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"left" : {
"kind" : "Identifier",
"location" : [ 25, 6, 25, 6 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"name" : "i"
},
"operator" : "+",
"right" : {
"kind" : "IntegerLiteral",
"location" : [ 25, 10, 25, 10 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 1
}
}
} ]
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}

@ -0,0 +1,43 @@
1
2
4
8
16
32
64
128
256
512
1024
2048
4096
8192
16384
32768
65536
131072
262144
524288
1048576
2097152
4194304
8388608
16777216
33554432
67108864
134217728
268435456
536870912
1073741824
1
2
4
8
16
32
64
128
256
512
1024
2048

@ -0,0 +1,30 @@
# Get the n-th prime starting from 2
def get_prime(n:int) -> int:
candidate:int = 2
found:int = 0
while True:
if is_prime(candidate):
found = found + 1
if found == n:
return candidate
candidate = candidate + 1
return 0 # Never happens
def is_prime(x:int) -> bool:
div:int = 2
while div < x:
if x % div == 0:
return False
div = div + 1
return True
# Input parameter
n:int = 15
# Run [1, n]
i:int = 1
# Crunch
while i <= n:
print(get_prime(i))
i = i + 1

@ -0,0 +1,658 @@
{
"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 ]
}
}

@ -0,0 +1,15 @@
2
3
5
7
11
13
17
19
23
29
31
37
41
43
47

@ -0,0 +1,107 @@
# A resizable list of integers
class Vector(object):
items: [int] = None
size: int = 0
def __init__(self:"Vector"):
self.items = [0]
# Returns current capacity
def capacity(self:"Vector") -> int:
return len(self.items)
# Increases capacity of vector by one element
def increase_capacity(self:"Vector") -> int:
self.items = self.items + [0]
return self.capacity()
# Appends one item to end of vector
def append(self:"Vector", item: int) -> object:
if self.size == self.capacity():
self.increase_capacity()
self.items[self.size] = item
self.size = self.size + 1
# Appends many items to end of vector
def append_all(self:"Vector", new_items: [int]) -> object:
item:int = 0
for item in new_items:
self.append(item)
# Removes an item from the middle of vector
def remove_at(self:"Vector", idx: int) -> object:
if idx < 0:
return
while idx < self.size - 1:
self.items[idx] = self.items[idx + 1]
idx = idx + 1
self.size = self.size - 1
# Retrieves an item at a given index
def get(self:"Vector", idx: int) -> int:
return self.items[idx]
# Retrieves the current size of the vector
def length(self:"Vector") -> int:
return self.size
# A faster (but more memory-consuming) implementation of vector
class DoublingVector(Vector):
doubling_limit:int = 1000
# Overriding to do fewer resizes
def increase_capacity(self:"DoublingVector") -> int:
if (self.capacity() <= self.doubling_limit // 2):
self.items = self.items + self.items
else:
# If doubling limit has been reached, fall back to
# standard capacity increases
self.items = self.items + [0]
return self.capacity()
# Makes a vector in the range [i, j)
def vrange(i:int, j:int) -> Vector:
v:Vector = None
v = DoublingVector()
while i < j:
v.append(i)
i = i + 1
return v
# Sieve of Eratosthenes (not really)
def sieve(v:Vector) -> object:
i:int = 0
j:int = 0
k:int = 0
while i < v.length():
k = v.get(i)
j = i + 1
while j < v.length():
if v.get(j) % k == 0:
v.remove_at(j)
else:
j = j + 1
i = i + 1
# Input parameter
n:int = 50
# Data
v:Vector = None
i:int = 0
# Crunch
v = vrange(2, n)
sieve(v)
# Print
while i < v.length():
print(v.get(i))
i = i + 1

File diff suppressed because it is too large Load Diff

@ -0,0 +1,15 @@
2
3
5
7
11
13
17
19
23
29
31
37
41
43
47

@ -0,0 +1,77 @@
# ChocoPy library functions
def int_to_str(x: int) -> str:
digits:[str] = None
result:str = ""
# Set-up digit mapping
digits = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
# Write sign if necessary
if x < 0:
result = "-"
x = -x
# Write digits using a recursive call
if x >= 10:
result = result + int_to_str(x // 10)
result = result + digits[x % 10]
return result
def str_to_int(x: str) -> int:
result:int = 0
digit:int = 0
char:str = ""
sign:int = 1
first_char:bool = True
# Parse digits
for char in x:
if char == "-":
if not first_char:
return 0 # Error
sign = -1
elif char == "0":
digit = 0
elif char == "1":
digit = 1
elif char == "2":
digit = 2
elif char == "3":
digit = 3
elif char == "3":
digit = 3
elif char == "4":
digit = 4
elif char == "5":
digit = 5
elif char == "6":
digit = 6
elif char == "7":
digit = 7
elif char == "8":
digit = 8
elif char == "9":
digit = 9
else:
return 0 # On error
first_char = False
result = result * 10 + digit
# Compute result
return result * sign
# Input parameters
c:int = 42
n:int = 10
# Run [-nc, nc] with step size c
s:str = ""
i:int = 0
i = -n * c
# Crunch
while i <= n * c:
s = int_to_str(i)
print(s)
i = str_to_int(s) + c

File diff suppressed because it is too large Load Diff

@ -0,0 +1,21 @@
-420
-378
-336
-294
-252
-210
-168
-126
-84
-42
0
42
84
126
168
210
252
294
336
378
420

@ -0,0 +1,83 @@
# Binary-search trees
class TreeNode(object):
value:int = 0
left:"TreeNode" = None
right:"TreeNode" = None
def insert(self:"TreeNode", x:int) -> bool:
if x < self.value:
if self.left is None:
self.left = makeNode(x)
return True
else:
return self.left.insert(x)
elif x > self.value:
if self.right is None:
self.right = makeNode(x)
return True
else:
return self.right.insert(x)
return False
def contains(self:"TreeNode", x:int) -> bool:
if x < self.value:
if self.left is None:
return False
else:
return self.left.contains(x)
elif x > self.value:
if self.right is None:
return False
else:
return self.right.contains(x)
else:
return True
class Tree(object):
root:TreeNode = None
size:int = 0
def insert(self:"Tree", x:int) -> object:
if self.root is None:
self.root = makeNode(x)
self.size = 1
else:
if self.root.insert(x):
self.size = self.size + 1
def contains(self:"Tree", x:int) -> bool:
if self.root is None:
return False
else:
return self.root.contains(x)
def makeNode(x: int) -> TreeNode:
b:TreeNode = None
b = TreeNode()
b.value = x
return b
# Input parameters
n:int = 100
c:int = 4
# Data
t:Tree = None
i:int = 0
k:int = 37813
# Crunch
t = Tree()
while i < n:
t.insert(k)
k = (k * 37813) % 37831
if i % c != 0:
t.insert(i)
i = i + 1
print(t.size)
for i in [4, 8, 15, 16, 23, 42]:
if t.contains(i):
print(i)

File diff suppressed because it is too large Load Diff

Binary file not shown.

@ -0,0 +1,17 @@
def f() -> int:
print("start f")
g()
print("end f")
return 42
def g() -> object:
print("start g")
h()
print("end g")
def h() -> object:
print("start h")
print("end h")
print(f())

@ -0,0 +1,386 @@
{
"kind" : "Program",
"location" : [ 1, 1, 17, 11 ],
"declarations" : [ {
"kind" : "FuncDef",
"location" : [ 1, 1, 5, 14 ],
"name" : {
"kind" : "Identifier",
"location" : [ 1, 5, 1, 5 ],
"name" : "f"
},
"params" : [ ],
"returnType" : {
"kind" : "ClassType",
"location" : [ 1, 12, 1, 14 ],
"className" : "int"
},
"declarations" : [ ],
"statements" : [ {
"kind" : "ExprStmt",
"location" : [ 2, 5, 2, 20 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 2, 5, 2, 20 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
},
"function" : {
"kind" : "Identifier",
"location" : [ 2, 5, 2, 9 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
},
"name" : "print"
},
"args" : [ {
"kind" : "StringLiteral",
"location" : [ 2, 11, 2, 19 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "str"
},
"value" : "start f"
} ]
}
}, {
"kind" : "ExprStmt",
"location" : [ 3, 5, 3, 7 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 3, 5, 3, 7 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "object"
},
"function" : {
"kind" : "Identifier",
"location" : [ 3, 5, 3, 5 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "object"
}
},
"name" : "g"
},
"args" : [ ]
}
}, {
"kind" : "ExprStmt",
"location" : [ 4, 5, 4, 18 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 4, 5, 4, 18 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
},
"function" : {
"kind" : "Identifier",
"location" : [ 4, 5, 4, 9 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
},
"name" : "print"
},
"args" : [ {
"kind" : "StringLiteral",
"location" : [ 4, 11, 4, 17 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "str"
},
"value" : "end f"
} ]
}
}, {
"kind" : "ReturnStmt",
"location" : [ 5, 5, 5, 13 ],
"value" : {
"kind" : "IntegerLiteral",
"location" : [ 5, 12, 5, 13 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 42
}
} ]
}, {
"kind" : "FuncDef",
"location" : [ 8, 1, 11, 19 ],
"name" : {
"kind" : "Identifier",
"location" : [ 8, 5, 8, 5 ],
"name" : "g"
},
"params" : [ ],
"returnType" : {
"kind" : "ClassType",
"location" : [ 8, 12, 8, 17 ],
"className" : "object"
},
"declarations" : [ ],
"statements" : [ {
"kind" : "ExprStmt",
"location" : [ 9, 5, 9, 20 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 9, 5, 9, 20 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
},
"function" : {
"kind" : "Identifier",
"location" : [ 9, 5, 9, 9 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
},
"name" : "print"
},
"args" : [ {
"kind" : "StringLiteral",
"location" : [ 9, 11, 9, 19 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "str"
},
"value" : "start g"
} ]
}
}, {
"kind" : "ExprStmt",
"location" : [ 10, 5, 10, 7 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 10, 5, 10, 7 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "object"
},
"function" : {
"kind" : "Identifier",
"location" : [ 10, 5, 10, 5 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "object"
}
},
"name" : "h"
},
"args" : [ ]
}
}, {
"kind" : "ExprStmt",
"location" : [ 11, 5, 11, 18 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 11, 5, 11, 18 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
},
"function" : {
"kind" : "Identifier",
"location" : [ 11, 5, 11, 9 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
},
"name" : "print"
},
"args" : [ {
"kind" : "StringLiteral",
"location" : [ 11, 11, 11, 17 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "str"
},
"value" : "end g"
} ]
}
} ]
}, {
"kind" : "FuncDef",
"location" : [ 13, 1, 15, 19 ],
"name" : {
"kind" : "Identifier",
"location" : [ 13, 5, 13, 5 ],
"name" : "h"
},
"params" : [ ],
"returnType" : {
"kind" : "ClassType",
"location" : [ 13, 12, 13, 17 ],
"className" : "object"
},
"declarations" : [ ],
"statements" : [ {
"kind" : "ExprStmt",
"location" : [ 14, 5, 14, 20 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 14, 5, 14, 20 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
},
"function" : {
"kind" : "Identifier",
"location" : [ 14, 5, 14, 9 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
},
"name" : "print"
},
"args" : [ {
"kind" : "StringLiteral",
"location" : [ 14, 11, 14, 19 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "str"
},
"value" : "start h"
} ]
}
}, {
"kind" : "ExprStmt",
"location" : [ 15, 5, 15, 18 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 15, 5, 15, 18 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
},
"function" : {
"kind" : "Identifier",
"location" : [ 15, 5, 15, 9 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
},
"name" : "print"
},
"args" : [ {
"kind" : "StringLiteral",
"location" : [ 15, 11, 15, 17 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "str"
},
"value" : "end h"
} ]
}
} ]
} ],
"statements" : [ {
"kind" : "ExprStmt",
"location" : [ 17, 1, 17, 10 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 17, 1, 17, 10 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
},
"function" : {
"kind" : "Identifier",
"location" : [ 17, 1, 17, 5 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
},
"name" : "print"
},
"args" : [ {
"kind" : "CallExpr",
"location" : [ 17, 7, 17, 9 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"function" : {
"kind" : "Identifier",
"location" : [ 17, 7, 17, 7 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "f"
},
"args" : [ ]
} ]
}
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}

@ -0,0 +1,7 @@
start f
start g
start h
end h
end g
end f
42

@ -0,0 +1,19 @@
def f(x:int) -> int:
print("start f")
print(x)
g(1, x)
print("end f")
return x
def g(y:int, z:int) -> object:
print("start g")
print(y)
print(z)
h("h")
print("end g")
def h(msg: str) -> object:
print(msg)
print(f(4))

@ -0,0 +1,554 @@
{
"kind" : "Program",
"location" : [ 1, 1, 19, 12 ],
"declarations" : [ {
"kind" : "FuncDef",
"location" : [ 1, 1, 6, 13 ],
"name" : {
"kind" : "Identifier",
"location" : [ 1, 5, 1, 5 ],
"name" : "f"
},
"params" : [ {
"kind" : "TypedVar",
"location" : [ 1, 7, 1, 11 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 1, 7, 1, 7 ],
"name" : "x"
},
"type" : {
"kind" : "ClassType",
"location" : [ 1, 9, 1, 11 ],
"className" : "int"
}
} ],
"returnType" : {
"kind" : "ClassType",
"location" : [ 1, 17, 1, 19 ],
"className" : "int"
},
"declarations" : [ ],
"statements" : [ {
"kind" : "ExprStmt",
"location" : [ 2, 5, 2, 20 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 2, 5, 2, 20 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
},
"function" : {
"kind" : "Identifier",
"location" : [ 2, 5, 2, 9 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
},
"name" : "print"
},
"args" : [ {
"kind" : "StringLiteral",
"location" : [ 2, 11, 2, 19 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "str"
},
"value" : "start f"
} ]
}
}, {
"kind" : "ExprStmt",
"location" : [ 3, 5, 3, 12 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 3, 5, 3, 12 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
},
"function" : {
"kind" : "Identifier",
"location" : [ 3, 5, 3, 9 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
},
"name" : "print"
},
"args" : [ {
"kind" : "Identifier",
"location" : [ 3, 11, 3, 11 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"name" : "x"
} ]
}
}, {
"kind" : "ExprStmt",
"location" : [ 4, 5, 4, 11 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 4, 5, 4, 11 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "object"
},
"function" : {
"kind" : "Identifier",
"location" : [ 4, 5, 4, 5 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "int"
}, {
"kind" : "ClassValueType",
"className" : "int"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "object"
}
},
"name" : "g"
},
"args" : [ {
"kind" : "IntegerLiteral",
"location" : [ 4, 7, 4, 7 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 1
}, {
"kind" : "Identifier",
"location" : [ 4, 10, 4, 10 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"name" : "x"
} ]
}
}, {
"kind" : "ExprStmt",
"location" : [ 5, 5, 5, 18 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 5, 5, 5, 18 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
},
"function" : {
"kind" : "Identifier",
"location" : [ 5, 5, 5, 9 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
},
"name" : "print"
},
"args" : [ {
"kind" : "StringLiteral",
"location" : [ 5, 11, 5, 17 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "str"
},
"value" : "end f"
} ]
}
}, {
"kind" : "ReturnStmt",
"location" : [ 6, 5, 6, 12 ],
"value" : {
"kind" : "Identifier",
"location" : [ 6, 12, 6, 12 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"name" : "x"
}
} ]
}, {
"kind" : "FuncDef",
"location" : [ 9, 1, 14, 19 ],
"name" : {
"kind" : "Identifier",
"location" : [ 9, 5, 9, 5 ],
"name" : "g"
},
"params" : [ {
"kind" : "TypedVar",
"location" : [ 9, 7, 9, 11 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 9, 7, 9, 7 ],
"name" : "y"
},
"type" : {
"kind" : "ClassType",
"location" : [ 9, 9, 9, 11 ],
"className" : "int"
}
}, {
"kind" : "TypedVar",
"location" : [ 9, 14, 9, 18 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 9, 14, 9, 14 ],
"name" : "z"
},
"type" : {
"kind" : "ClassType",
"location" : [ 9, 16, 9, 18 ],
"className" : "int"
}
} ],
"returnType" : {
"kind" : "ClassType",
"location" : [ 9, 24, 9, 29 ],
"className" : "object"
},
"declarations" : [ ],
"statements" : [ {
"kind" : "ExprStmt",
"location" : [ 10, 5, 10, 20 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 10, 5, 10, 20 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
},
"function" : {
"kind" : "Identifier",
"location" : [ 10, 5, 10, 9 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
},
"name" : "print"
},
"args" : [ {
"kind" : "StringLiteral",
"location" : [ 10, 11, 10, 19 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "str"
},
"value" : "start g"
} ]
}
}, {
"kind" : "ExprStmt",
"location" : [ 11, 5, 11, 12 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 11, 5, 11, 12 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
},
"function" : {
"kind" : "Identifier",
"location" : [ 11, 5, 11, 9 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
},
"name" : "print"
},
"args" : [ {
"kind" : "Identifier",
"location" : [ 11, 11, 11, 11 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"name" : "y"
} ]
}
}, {
"kind" : "ExprStmt",
"location" : [ 12, 5, 12, 12 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 12, 5, 12, 12 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
},
"function" : {
"kind" : "Identifier",
"location" : [ 12, 5, 12, 9 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
},
"name" : "print"
},
"args" : [ {
"kind" : "Identifier",
"location" : [ 12, 11, 12, 11 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"name" : "z"
} ]
}
}, {
"kind" : "ExprStmt",
"location" : [ 13, 5, 13, 10 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 13, 5, 13, 10 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "object"
},
"function" : {
"kind" : "Identifier",
"location" : [ 13, 5, 13, 5 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "str"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "object"
}
},
"name" : "h"
},
"args" : [ {
"kind" : "StringLiteral",
"location" : [ 13, 7, 13, 9 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "str"
},
"value" : "h"
} ]
}
}, {
"kind" : "ExprStmt",
"location" : [ 14, 5, 14, 18 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 14, 5, 14, 18 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
},
"function" : {
"kind" : "Identifier",
"location" : [ 14, 5, 14, 9 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
},
"name" : "print"
},
"args" : [ {
"kind" : "StringLiteral",
"location" : [ 14, 11, 14, 17 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "str"
},
"value" : "end g"
} ]
}
} ]
}, {
"kind" : "FuncDef",
"location" : [ 16, 1, 17, 15 ],
"name" : {
"kind" : "Identifier",
"location" : [ 16, 5, 16, 5 ],
"name" : "h"
},
"params" : [ {
"kind" : "TypedVar",
"location" : [ 16, 7, 16, 14 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 16, 7, 16, 9 ],
"name" : "msg"
},
"type" : {
"kind" : "ClassType",
"location" : [ 16, 12, 16, 14 ],
"className" : "str"
}
} ],
"returnType" : {
"kind" : "ClassType",
"location" : [ 16, 20, 16, 25 ],
"className" : "object"
},
"declarations" : [ ],
"statements" : [ {
"kind" : "ExprStmt",
"location" : [ 17, 5, 17, 14 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 17, 5, 17, 14 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
},
"function" : {
"kind" : "Identifier",
"location" : [ 17, 5, 17, 9 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
},
"name" : "print"
},
"args" : [ {
"kind" : "Identifier",
"location" : [ 17, 11, 17, 13 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "str"
},
"name" : "msg"
} ]
}
} ]
} ],
"statements" : [ {
"kind" : "ExprStmt",
"location" : [ 19, 1, 19, 11 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 19, 1, 19, 11 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
},
"function" : {
"kind" : "Identifier",
"location" : [ 19, 1, 19, 5 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
},
"name" : "print"
},
"args" : [ {
"kind" : "CallExpr",
"location" : [ 19, 7, 19, 10 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"function" : {
"kind" : "Identifier",
"location" : [ 19, 7, 19, 7 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "int"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "f"
},
"args" : [ {
"kind" : "IntegerLiteral",
"location" : [ 19, 9, 19, 9 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 4
} ]
} ]
}
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}

@ -0,0 +1,9 @@
start f
4
start g
1
4
h
end g
end f
4

@ -0,0 +1,65 @@
{
"kind" : "Program",
"location" : [ 1, 1, 1, 15 ],
"declarations" : [ ],
"statements" : [ {
"kind" : "ExprStmt",
"location" : [ 1, 1, 1, 14 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 1, 1, 1, 14 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
},
"function" : {
"kind" : "Identifier",
"location" : [ 1, 1, 1, 5 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
},
"name" : "print"
},
"args" : [ {
"kind" : "BinaryExpr",
"location" : [ 1, 7, 1, 13 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"left" : {
"kind" : "IntegerLiteral",
"location" : [ 1, 7, 1, 8 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 42
},
"operator" : "//",
"right" : {
"kind" : "IntegerLiteral",
"location" : [ 1, 13, 1, 13 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 0
}
} ]
}
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}

@ -0,0 +1,2 @@
Division by zero
Exited with error code 2

@ -0,0 +1,46 @@
{
"kind" : "Program",
"location" : [ 1, 1, 1, 12 ],
"declarations" : [ ],
"statements" : [ {
"kind" : "ExprStmt",
"location" : [ 1, 1, 1, 11 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 1, 1, 1, 11 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
},
"function" : {
"kind" : "Identifier",
"location" : [ 1, 1, 1, 5 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
},
"name" : "print"
},
"args" : [ {
"kind" : "NoneLiteral",
"location" : [ 1, 7, 1, 10 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
} ]
}
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}

@ -0,0 +1,2 @@
Invalid argument
Exited with error code 1

@ -0,0 +1,65 @@
{
"kind" : "Program",
"location" : [ 1, 1, 1, 14 ],
"declarations" : [ ],
"statements" : [ {
"kind" : "ExprStmt",
"location" : [ 1, 1, 1, 13 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 1, 1, 1, 13 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
},
"function" : {
"kind" : "Identifier",
"location" : [ 1, 1, 1, 5 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
},
"name" : "print"
},
"args" : [ {
"kind" : "BinaryExpr",
"location" : [ 1, 7, 1, 12 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"left" : {
"kind" : "IntegerLiteral",
"location" : [ 1, 7, 1, 8 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 42
},
"operator" : "%",
"right" : {
"kind" : "IntegerLiteral",
"location" : [ 1, 12, 1, 12 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 0
}
} ]
}
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}

@ -0,0 +1,2 @@
Division by zero
Exited with error code 2

@ -0,0 +1,2 @@
print(3 if True else 4)
print(3 if False else 4)

@ -0,0 +1,135 @@
{
"kind" : "Program",
"location" : [ 1, 1, 2, 25 ],
"declarations" : [ ],
"statements" : [ {
"kind" : "ExprStmt",
"location" : [ 1, 1, 1, 23 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 1, 1, 1, 23 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
},
"function" : {
"kind" : "Identifier",
"location" : [ 1, 1, 1, 5 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
},
"name" : "print"
},
"args" : [ {
"kind" : "IfExpr",
"location" : [ 1, 7, 1, 22 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"condition" : {
"kind" : "BooleanLiteral",
"location" : [ 1, 12, 1, 15 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "bool"
},
"value" : true
},
"thenExpr" : {
"kind" : "IntegerLiteral",
"location" : [ 1, 7, 1, 7 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 3
},
"elseExpr" : {
"kind" : "IntegerLiteral",
"location" : [ 1, 22, 1, 22 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 4
}
} ]
}
}, {
"kind" : "ExprStmt",
"location" : [ 2, 1, 2, 24 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 2, 1, 2, 24 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
},
"function" : {
"kind" : "Identifier",
"location" : [ 2, 1, 2, 5 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
},
"name" : "print"
},
"args" : [ {
"kind" : "IfExpr",
"location" : [ 2, 7, 2, 23 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"condition" : {
"kind" : "BooleanLiteral",
"location" : [ 2, 12, 2, 16 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "bool"
},
"value" : false
},
"thenExpr" : {
"kind" : "IntegerLiteral",
"location" : [ 2, 7, 2, 7 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 3
},
"elseExpr" : {
"kind" : "IntegerLiteral",
"location" : [ 2, 23, 2, 23 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 4
}
} ]
}
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}

@ -0,0 +1,2 @@
x:int = 42
print(x)

@ -0,0 +1,73 @@
{
"kind" : "Program",
"location" : [ 1, 1, 2, 9 ],
"declarations" : [ {
"kind" : "VarDef",
"location" : [ 1, 1, 1, 10 ],
"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, 10 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 42
}
} ],
"statements" : [ {
"kind" : "ExprStmt",
"location" : [ 2, 1, 2, 8 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 2, 1, 2, 8 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
},
"function" : {
"kind" : "Identifier",
"location" : [ 2, 1, 2, 5 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
},
"name" : "print"
},
"args" : [ {
"kind" : "Identifier",
"location" : [ 2, 7, 2, 7 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"name" : "x"
} ]
}
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}

@ -0,0 +1,5 @@
def f() -> int:
x:int = 1
return x
print(f())

@ -0,0 +1,114 @@
{
"kind" : "Program",
"location" : [ 1, 1, 5, 11 ],
"declarations" : [ {
"kind" : "FuncDef",
"location" : [ 1, 1, 3, 11 ],
"name" : {
"kind" : "Identifier",
"location" : [ 1, 5, 1, 5 ],
"name" : "f"
},
"params" : [ ],
"returnType" : {
"kind" : "ClassType",
"location" : [ 1, 12, 1, 14 ],
"className" : "int"
},
"declarations" : [ {
"kind" : "VarDef",
"location" : [ 2, 3, 2, 11 ],
"var" : {
"kind" : "TypedVar",
"location" : [ 2, 3, 2, 7 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 2, 3, 2, 3 ],
"name" : "x"
},
"type" : {
"kind" : "ClassType",
"location" : [ 2, 5, 2, 7 ],
"className" : "int"
}
},
"value" : {
"kind" : "IntegerLiteral",
"location" : [ 2, 11, 2, 11 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 1
}
} ],
"statements" : [ {
"kind" : "ReturnStmt",
"location" : [ 3, 3, 3, 10 ],
"value" : {
"kind" : "Identifier",
"location" : [ 3, 10, 3, 10 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"name" : "x"
}
} ]
} ],
"statements" : [ {
"kind" : "ExprStmt",
"location" : [ 5, 1, 5, 10 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 5, 1, 5, 10 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
},
"function" : {
"kind" : "Identifier",
"location" : [ 5, 1, 5, 5 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
},
"name" : "print"
},
"args" : [ {
"kind" : "CallExpr",
"location" : [ 5, 7, 5, 9 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"function" : {
"kind" : "Identifier",
"location" : [ 5, 7, 5, 7 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "f"
},
"args" : [ ]
} ]
}
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}

@ -0,0 +1,8 @@
# Test of 'input' function.
s: str = ""
s = input()
while len(s) > 0:
print(s)
s = input()

@ -0,0 +1,4 @@
First line.
Next line is blank.
Last line.

@ -0,0 +1,196 @@
{
"kind" : "Program",
"location" : [ 3, 1, 9, 1 ],
"declarations" : [ {
"kind" : "VarDef",
"location" : [ 3, 1, 3, 11 ],
"var" : {
"kind" : "TypedVar",
"location" : [ 3, 1, 3, 6 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 3, 1, 3, 1 ],
"name" : "s"
},
"type" : {
"kind" : "ClassType",
"location" : [ 3, 4, 3, 6 ],
"className" : "str"
}
},
"value" : {
"kind" : "StringLiteral",
"location" : [ 3, 10, 3, 11 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "str"
},
"value" : ""
}
} ],
"statements" : [ {
"kind" : "AssignStmt",
"location" : [ 5, 1, 5, 11 ],
"targets" : [ {
"kind" : "Identifier",
"location" : [ 5, 1, 5, 1 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "str"
},
"name" : "s"
} ],
"value" : {
"kind" : "CallExpr",
"location" : [ 5, 5, 5, 11 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "str"
},
"function" : {
"kind" : "Identifier",
"location" : [ 5, 5, 5, 9 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "str"
}
},
"name" : "input"
},
"args" : [ ]
}
}, {
"kind" : "WhileStmt",
"location" : [ 6, 1, 9, 1 ],
"condition" : {
"kind" : "BinaryExpr",
"location" : [ 6, 7, 6, 16 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "bool"
},
"left" : {
"kind" : "CallExpr",
"location" : [ 6, 7, 6, 12 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"function" : {
"kind" : "Identifier",
"location" : [ 6, 7, 6, 9 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "len"
},
"args" : [ {
"kind" : "Identifier",
"location" : [ 6, 11, 6, 11 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "str"
},
"name" : "s"
} ]
},
"operator" : ">",
"right" : {
"kind" : "IntegerLiteral",
"location" : [ 6, 16, 6, 16 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 0
}
},
"body" : [ {
"kind" : "ExprStmt",
"location" : [ 7, 5, 7, 12 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 7, 5, 7, 12 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
},
"function" : {
"kind" : "Identifier",
"location" : [ 7, 5, 7, 9 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
},
"name" : "print"
},
"args" : [ {
"kind" : "Identifier",
"location" : [ 7, 11, 7, 11 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "str"
},
"name" : "s"
} ]
}
}, {
"kind" : "AssignStmt",
"location" : [ 8, 5, 8, 15 ],
"targets" : [ {
"kind" : "Identifier",
"location" : [ 8, 5, 8, 5 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "str"
},
"name" : "s"
} ],
"value" : {
"kind" : "CallExpr",
"location" : [ 8, 9, 8, 15 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "str"
},
"function" : {
"kind" : "Identifier",
"location" : [ 8, 9, 8, 13 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "str"
}
},
"name" : "input"
},
"args" : [ ]
}
} ]
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}

@ -0,0 +1,4 @@
First line.
Next line is blank.
Last line.

@ -0,0 +1,8 @@
First line.
Next line is blank.
Last line.

@ -0,0 +1,4 @@
First line.
Next line is blank.
Last line.

@ -0,0 +1,3 @@
x:[int] = None
print(len(x))

@ -0,0 +1,103 @@
{
"kind" : "Program",
"location" : [ 1, 1, 3, 14 ],
"declarations" : [ {
"kind" : "VarDef",
"location" : [ 1, 1, 1, 14 ],
"var" : {
"kind" : "TypedVar",
"location" : [ 1, 1, 1, 7 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 1, 1, 1, 1 ],
"name" : "x"
},
"type" : {
"kind" : "ListType",
"location" : [ 1, 3, 1, 7 ],
"elementType" : {
"kind" : "ClassType",
"location" : [ 1, 4, 1, 6 ],
"className" : "int"
}
}
},
"value" : {
"kind" : "NoneLiteral",
"location" : [ 1, 11, 1, 14 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
}
} ],
"statements" : [ {
"kind" : "ExprStmt",
"location" : [ 3, 1, 3, 13 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 3, 1, 3, 13 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
},
"function" : {
"kind" : "Identifier",
"location" : [ 3, 1, 3, 5 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
},
"name" : "print"
},
"args" : [ {
"kind" : "CallExpr",
"location" : [ 3, 7, 3, 12 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"function" : {
"kind" : "Identifier",
"location" : [ 3, 7, 3, 9 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "len"
},
"args" : [ {
"kind" : "Identifier",
"location" : [ 3, 11, 3, 11 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "x"
} ]
} ]
}
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}

@ -0,0 +1,2 @@
Invalid argument
Exited with error code 1

@ -0,0 +1,3 @@
x:int = 1
print(len(x))

@ -0,0 +1,97 @@
{
"kind" : "Program",
"location" : [ 1, 1, 3, 14 ],
"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 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 1
}
} ],
"statements" : [ {
"kind" : "ExprStmt",
"location" : [ 3, 1, 3, 13 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 3, 1, 3, 13 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
},
"function" : {
"kind" : "Identifier",
"location" : [ 3, 1, 3, 5 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
},
"name" : "print"
},
"args" : [ {
"kind" : "CallExpr",
"location" : [ 3, 7, 3, 12 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"function" : {
"kind" : "Identifier",
"location" : [ 3, 7, 3, 9 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "len"
},
"args" : [ {
"kind" : "Identifier",
"location" : [ 3, 11, 3, 11 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"name" : "x"
} ]
} ]
}
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}

@ -0,0 +1,2 @@
Invalid argument
Exited with error code 1

@ -0,0 +1,12 @@
def concat(x:[int], y:[int]) -> [int]:
return x + y
z:[int] = None
i:int = 0
z = concat([1,2,3], [4,5,6])
while i < len(z):
print(z[i])
i = i + 1

@ -0,0 +1,437 @@
{
"kind" : "Program",
"location" : [ 1, 1, 13, 1 ],
"declarations" : [ {
"kind" : "FuncDef",
"location" : [ 1, 1, 2, 17 ],
"name" : {
"kind" : "Identifier",
"location" : [ 1, 5, 1, 10 ],
"name" : "concat"
},
"params" : [ {
"kind" : "TypedVar",
"location" : [ 1, 12, 1, 18 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 1, 12, 1, 12 ],
"name" : "x"
},
"type" : {
"kind" : "ListType",
"location" : [ 1, 14, 1, 18 ],
"elementType" : {
"kind" : "ClassType",
"location" : [ 1, 15, 1, 17 ],
"className" : "int"
}
}
}, {
"kind" : "TypedVar",
"location" : [ 1, 21, 1, 27 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 1, 21, 1, 21 ],
"name" : "y"
},
"type" : {
"kind" : "ListType",
"location" : [ 1, 23, 1, 27 ],
"elementType" : {
"kind" : "ClassType",
"location" : [ 1, 24, 1, 26 ],
"className" : "int"
}
}
} ],
"returnType" : {
"kind" : "ListType",
"location" : [ 1, 33, 1, 37 ],
"elementType" : {
"kind" : "ClassType",
"location" : [ 1, 34, 1, 36 ],
"className" : "int"
}
},
"declarations" : [ ],
"statements" : [ {
"kind" : "ReturnStmt",
"location" : [ 2, 5, 2, 16 ],
"value" : {
"kind" : "BinaryExpr",
"location" : [ 2, 12, 2, 16 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"left" : {
"kind" : "Identifier",
"location" : [ 2, 12, 2, 12 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "x"
},
"operator" : "+",
"right" : {
"kind" : "Identifier",
"location" : [ 2, 16, 2, 16 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "y"
}
}
} ]
}, {
"kind" : "VarDef",
"location" : [ 4, 1, 4, 14 ],
"var" : {
"kind" : "TypedVar",
"location" : [ 4, 1, 4, 7 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 4, 1, 4, 1 ],
"name" : "z"
},
"type" : {
"kind" : "ListType",
"location" : [ 4, 3, 4, 7 ],
"elementType" : {
"kind" : "ClassType",
"location" : [ 4, 4, 4, 6 ],
"className" : "int"
}
}
},
"value" : {
"kind" : "NoneLiteral",
"location" : [ 4, 11, 4, 14 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
}
}, {
"kind" : "VarDef",
"location" : [ 5, 1, 5, 9 ],
"var" : {
"kind" : "TypedVar",
"location" : [ 5, 1, 5, 5 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 5, 1, 5, 1 ],
"name" : "i"
},
"type" : {
"kind" : "ClassType",
"location" : [ 5, 3, 5, 5 ],
"className" : "int"
}
},
"value" : {
"kind" : "IntegerLiteral",
"location" : [ 5, 9, 5, 9 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 0
}
} ],
"statements" : [ {
"kind" : "AssignStmt",
"location" : [ 7, 1, 7, 28 ],
"targets" : [ {
"kind" : "Identifier",
"location" : [ 7, 1, 7, 1 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "z"
} ],
"value" : {
"kind" : "CallExpr",
"location" : [ 7, 5, 7, 28 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"function" : {
"kind" : "Identifier",
"location" : [ 7, 5, 7, 10 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
}, {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
} ],
"returnType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
}
},
"name" : "concat"
},
"args" : [ {
"kind" : "ListExpr",
"location" : [ 7, 12, 7, 18 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"elements" : [ {
"kind" : "IntegerLiteral",
"location" : [ 7, 13, 7, 13 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 1
}, {
"kind" : "IntegerLiteral",
"location" : [ 7, 15, 7, 15 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 2
}, {
"kind" : "IntegerLiteral",
"location" : [ 7, 17, 7, 17 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 3
} ]
}, {
"kind" : "ListExpr",
"location" : [ 7, 21, 7, 27 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"elements" : [ {
"kind" : "IntegerLiteral",
"location" : [ 7, 22, 7, 22 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 4
}, {
"kind" : "IntegerLiteral",
"location" : [ 7, 24, 7, 24 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 5
}, {
"kind" : "IntegerLiteral",
"location" : [ 7, 26, 7, 26 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 6
} ]
} ]
}
}, {
"kind" : "WhileStmt",
"location" : [ 9, 1, 13, 1 ],
"condition" : {
"kind" : "BinaryExpr",
"location" : [ 9, 7, 9, 16 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "bool"
},
"left" : {
"kind" : "Identifier",
"location" : [ 9, 7, 9, 7 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"name" : "i"
},
"operator" : "<",
"right" : {
"kind" : "CallExpr",
"location" : [ 9, 11, 9, 16 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"function" : {
"kind" : "Identifier",
"location" : [ 9, 11, 9, 13 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "len"
},
"args" : [ {
"kind" : "Identifier",
"location" : [ 9, 15, 9, 15 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "z"
} ]
}
},
"body" : [ {
"kind" : "ExprStmt",
"location" : [ 10, 5, 10, 15 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 10, 5, 10, 15 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
},
"function" : {
"kind" : "Identifier",
"location" : [ 10, 5, 10, 9 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
},
"name" : "print"
},
"args" : [ {
"kind" : "IndexExpr",
"location" : [ 10, 11, 10, 14 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"list" : {
"kind" : "Identifier",
"location" : [ 10, 11, 10, 11 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "z"
},
"index" : {
"kind" : "Identifier",
"location" : [ 10, 13, 10, 13 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"name" : "i"
}
} ]
}
}, {
"kind" : "AssignStmt",
"location" : [ 11, 5, 11, 13 ],
"targets" : [ {
"kind" : "Identifier",
"location" : [ 11, 5, 11, 5 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"name" : "i"
} ],
"value" : {
"kind" : "BinaryExpr",
"location" : [ 11, 9, 11, 13 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"left" : {
"kind" : "Identifier",
"location" : [ 11, 9, 11, 9 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"name" : "i"
},
"operator" : "+",
"right" : {
"kind" : "IntegerLiteral",
"location" : [ 11, 13, 11, 13 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 1
}
}
} ]
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}

@ -0,0 +1,8 @@
z:[int] = None
i:int = 0
z = [1,2,3] + [4,5,6] + [7,8,9]
while i < len(z):
print(z[i])
i = i + 1

@ -0,0 +1,366 @@
{
"kind" : "Program",
"location" : [ 1, 1, 9, 1 ],
"declarations" : [ {
"kind" : "VarDef",
"location" : [ 1, 1, 1, 14 ],
"var" : {
"kind" : "TypedVar",
"location" : [ 1, 1, 1, 7 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 1, 1, 1, 1 ],
"name" : "z"
},
"type" : {
"kind" : "ListType",
"location" : [ 1, 3, 1, 7 ],
"elementType" : {
"kind" : "ClassType",
"location" : [ 1, 4, 1, 6 ],
"className" : "int"
}
}
},
"value" : {
"kind" : "NoneLiteral",
"location" : [ 1, 11, 1, 14 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
}
}, {
"kind" : "VarDef",
"location" : [ 2, 1, 2, 9 ],
"var" : {
"kind" : "TypedVar",
"location" : [ 2, 1, 2, 5 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 2, 1, 2, 1 ],
"name" : "i"
},
"type" : {
"kind" : "ClassType",
"location" : [ 2, 3, 2, 5 ],
"className" : "int"
}
},
"value" : {
"kind" : "IntegerLiteral",
"location" : [ 2, 9, 2, 9 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 0
}
} ],
"statements" : [ {
"kind" : "AssignStmt",
"location" : [ 4, 1, 4, 31 ],
"targets" : [ {
"kind" : "Identifier",
"location" : [ 4, 1, 4, 1 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "z"
} ],
"value" : {
"kind" : "BinaryExpr",
"location" : [ 4, 5, 4, 31 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"left" : {
"kind" : "BinaryExpr",
"location" : [ 4, 5, 4, 21 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"left" : {
"kind" : "ListExpr",
"location" : [ 4, 5, 4, 11 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"elements" : [ {
"kind" : "IntegerLiteral",
"location" : [ 4, 6, 4, 6 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 1
}, {
"kind" : "IntegerLiteral",
"location" : [ 4, 8, 4, 8 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 2
}, {
"kind" : "IntegerLiteral",
"location" : [ 4, 10, 4, 10 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 3
} ]
},
"operator" : "+",
"right" : {
"kind" : "ListExpr",
"location" : [ 4, 15, 4, 21 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"elements" : [ {
"kind" : "IntegerLiteral",
"location" : [ 4, 16, 4, 16 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 4
}, {
"kind" : "IntegerLiteral",
"location" : [ 4, 18, 4, 18 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 5
}, {
"kind" : "IntegerLiteral",
"location" : [ 4, 20, 4, 20 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 6
} ]
}
},
"operator" : "+",
"right" : {
"kind" : "ListExpr",
"location" : [ 4, 25, 4, 31 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"elements" : [ {
"kind" : "IntegerLiteral",
"location" : [ 4, 26, 4, 26 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 7
}, {
"kind" : "IntegerLiteral",
"location" : [ 4, 28, 4, 28 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 8
}, {
"kind" : "IntegerLiteral",
"location" : [ 4, 30, 4, 30 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 9
} ]
}
}
}, {
"kind" : "WhileStmt",
"location" : [ 6, 1, 9, 1 ],
"condition" : {
"kind" : "BinaryExpr",
"location" : [ 6, 7, 6, 16 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "bool"
},
"left" : {
"kind" : "Identifier",
"location" : [ 6, 7, 6, 7 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"name" : "i"
},
"operator" : "<",
"right" : {
"kind" : "CallExpr",
"location" : [ 6, 11, 6, 16 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"function" : {
"kind" : "Identifier",
"location" : [ 6, 11, 6, 13 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "len"
},
"args" : [ {
"kind" : "Identifier",
"location" : [ 6, 15, 6, 15 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "z"
} ]
}
},
"body" : [ {
"kind" : "ExprStmt",
"location" : [ 7, 5, 7, 15 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 7, 5, 7, 15 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
},
"function" : {
"kind" : "Identifier",
"location" : [ 7, 5, 7, 9 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
},
"name" : "print"
},
"args" : [ {
"kind" : "IndexExpr",
"location" : [ 7, 11, 7, 14 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"list" : {
"kind" : "Identifier",
"location" : [ 7, 11, 7, 11 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "z"
},
"index" : {
"kind" : "Identifier",
"location" : [ 7, 13, 7, 13 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"name" : "i"
}
} ]
}
}, {
"kind" : "AssignStmt",
"location" : [ 8, 5, 8, 13 ],
"targets" : [ {
"kind" : "Identifier",
"location" : [ 8, 5, 8, 5 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"name" : "i"
} ],
"value" : {
"kind" : "BinaryExpr",
"location" : [ 8, 9, 8, 13 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"left" : {
"kind" : "Identifier",
"location" : [ 8, 9, 8, 9 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"name" : "i"
},
"operator" : "+",
"right" : {
"kind" : "IntegerLiteral",
"location" : [ 8, 13, 8, 13 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 1
}
}
} ]
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}

@ -0,0 +1,4 @@
x:[int] = None
y:[int] = None
print(len(x+y))

@ -0,0 +1,156 @@
{
"kind" : "Program",
"location" : [ 1, 1, 4, 16 ],
"declarations" : [ {
"kind" : "VarDef",
"location" : [ 1, 1, 1, 14 ],
"var" : {
"kind" : "TypedVar",
"location" : [ 1, 1, 1, 7 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 1, 1, 1, 1 ],
"name" : "x"
},
"type" : {
"kind" : "ListType",
"location" : [ 1, 3, 1, 7 ],
"elementType" : {
"kind" : "ClassType",
"location" : [ 1, 4, 1, 6 ],
"className" : "int"
}
}
},
"value" : {
"kind" : "NoneLiteral",
"location" : [ 1, 11, 1, 14 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
}
}, {
"kind" : "VarDef",
"location" : [ 2, 1, 2, 14 ],
"var" : {
"kind" : "TypedVar",
"location" : [ 2, 1, 2, 7 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 2, 1, 2, 1 ],
"name" : "y"
},
"type" : {
"kind" : "ListType",
"location" : [ 2, 3, 2, 7 ],
"elementType" : {
"kind" : "ClassType",
"location" : [ 2, 4, 2, 6 ],
"className" : "int"
}
}
},
"value" : {
"kind" : "NoneLiteral",
"location" : [ 2, 11, 2, 14 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
}
} ],
"statements" : [ {
"kind" : "ExprStmt",
"location" : [ 4, 1, 4, 15 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 4, 1, 4, 15 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
},
"function" : {
"kind" : "Identifier",
"location" : [ 4, 1, 4, 5 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
},
"name" : "print"
},
"args" : [ {
"kind" : "CallExpr",
"location" : [ 4, 7, 4, 14 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"function" : {
"kind" : "Identifier",
"location" : [ 4, 7, 4, 9 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "len"
},
"args" : [ {
"kind" : "BinaryExpr",
"location" : [ 4, 11, 4, 13 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"left" : {
"kind" : "Identifier",
"location" : [ 4, 11, 4, 11 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "x"
},
"operator" : "+",
"right" : {
"kind" : "Identifier",
"location" : [ 4, 13, 4, 13 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "y"
}
} ]
} ]
}
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}

@ -0,0 +1,2 @@
Operation on None
Exited with error code 4

@ -0,0 +1,6 @@
x:[int] = None
x = [1, 2, 3]
print(x[0])
print(x[1])
print(x[2])

@ -0,0 +1,259 @@
{
"kind" : "Program",
"location" : [ 1, 1, 6, 12 ],
"declarations" : [ {
"kind" : "VarDef",
"location" : [ 1, 1, 1, 14 ],
"var" : {
"kind" : "TypedVar",
"location" : [ 1, 1, 1, 7 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 1, 1, 1, 1 ],
"name" : "x"
},
"type" : {
"kind" : "ListType",
"location" : [ 1, 3, 1, 7 ],
"elementType" : {
"kind" : "ClassType",
"location" : [ 1, 4, 1, 6 ],
"className" : "int"
}
}
},
"value" : {
"kind" : "NoneLiteral",
"location" : [ 1, 11, 1, 14 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
}
} ],
"statements" : [ {
"kind" : "AssignStmt",
"location" : [ 3, 1, 3, 13 ],
"targets" : [ {
"kind" : "Identifier",
"location" : [ 3, 1, 3, 1 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "x"
} ],
"value" : {
"kind" : "ListExpr",
"location" : [ 3, 5, 3, 13 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"elements" : [ {
"kind" : "IntegerLiteral",
"location" : [ 3, 6, 3, 6 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 1
}, {
"kind" : "IntegerLiteral",
"location" : [ 3, 9, 3, 9 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 2
}, {
"kind" : "IntegerLiteral",
"location" : [ 3, 12, 3, 12 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 3
} ]
}
}, {
"kind" : "ExprStmt",
"location" : [ 4, 1, 4, 11 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 4, 1, 4, 11 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
},
"function" : {
"kind" : "Identifier",
"location" : [ 4, 1, 4, 5 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
},
"name" : "print"
},
"args" : [ {
"kind" : "IndexExpr",
"location" : [ 4, 7, 4, 10 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"list" : {
"kind" : "Identifier",
"location" : [ 4, 7, 4, 7 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "x"
},
"index" : {
"kind" : "IntegerLiteral",
"location" : [ 4, 9, 4, 9 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 0
}
} ]
}
}, {
"kind" : "ExprStmt",
"location" : [ 5, 1, 5, 11 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 5, 1, 5, 11 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
},
"function" : {
"kind" : "Identifier",
"location" : [ 5, 1, 5, 5 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
},
"name" : "print"
},
"args" : [ {
"kind" : "IndexExpr",
"location" : [ 5, 7, 5, 10 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"list" : {
"kind" : "Identifier",
"location" : [ 5, 7, 5, 7 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "x"
},
"index" : {
"kind" : "IntegerLiteral",
"location" : [ 5, 9, 5, 9 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 1
}
} ]
}
}, {
"kind" : "ExprStmt",
"location" : [ 6, 1, 6, 11 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 6, 1, 6, 11 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
},
"function" : {
"kind" : "Identifier",
"location" : [ 6, 1, 6, 5 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
},
"name" : "print"
},
"args" : [ {
"kind" : "IndexExpr",
"location" : [ 6, 7, 6, 10 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"list" : {
"kind" : "Identifier",
"location" : [ 6, 7, 6, 7 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "x"
},
"index" : {
"kind" : "IntegerLiteral",
"location" : [ 6, 9, 6, 9 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 2
}
} ]
}
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}

@ -0,0 +1,11 @@
next:int = 0
def next_int() -> int:
global next
next = next + 1
return next
def make_list() -> [int]:
return [next_int(), next_int(), next_int()]
print(make_list()[next_int() - 3])

@ -0,0 +1,313 @@
{
"kind" : "Program",
"location" : [ 1, 1, 11, 35 ],
"declarations" : [ {
"kind" : "VarDef",
"location" : [ 1, 1, 1, 12 ],
"var" : {
"kind" : "TypedVar",
"location" : [ 1, 1, 1, 8 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 1, 1, 1, 4 ],
"name" : "next"
},
"type" : {
"kind" : "ClassType",
"location" : [ 1, 6, 1, 8 ],
"className" : "int"
}
},
"value" : {
"kind" : "IntegerLiteral",
"location" : [ 1, 12, 1, 12 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 0
}
}, {
"kind" : "FuncDef",
"location" : [ 3, 1, 6, 16 ],
"name" : {
"kind" : "Identifier",
"location" : [ 3, 5, 3, 12 ],
"name" : "next_int"
},
"params" : [ ],
"returnType" : {
"kind" : "ClassType",
"location" : [ 3, 19, 3, 21 ],
"className" : "int"
},
"declarations" : [ {
"kind" : "GlobalDecl",
"location" : [ 4, 5, 4, 15 ],
"variable" : {
"kind" : "Identifier",
"location" : [ 4, 12, 4, 15 ],
"name" : "next"
}
} ],
"statements" : [ {
"kind" : "AssignStmt",
"location" : [ 5, 5, 5, 19 ],
"targets" : [ {
"kind" : "Identifier",
"location" : [ 5, 5, 5, 8 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"name" : "next"
} ],
"value" : {
"kind" : "BinaryExpr",
"location" : [ 5, 12, 5, 19 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"left" : {
"kind" : "Identifier",
"location" : [ 5, 12, 5, 15 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"name" : "next"
},
"operator" : "+",
"right" : {
"kind" : "IntegerLiteral",
"location" : [ 5, 19, 5, 19 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 1
}
}
}, {
"kind" : "ReturnStmt",
"location" : [ 6, 5, 6, 15 ],
"value" : {
"kind" : "Identifier",
"location" : [ 6, 12, 6, 15 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"name" : "next"
}
} ]
}, {
"kind" : "FuncDef",
"location" : [ 8, 1, 9, 48 ],
"name" : {
"kind" : "Identifier",
"location" : [ 8, 5, 8, 13 ],
"name" : "make_list"
},
"params" : [ ],
"returnType" : {
"kind" : "ListType",
"location" : [ 8, 20, 8, 24 ],
"elementType" : {
"kind" : "ClassType",
"location" : [ 8, 21, 8, 23 ],
"className" : "int"
}
},
"declarations" : [ ],
"statements" : [ {
"kind" : "ReturnStmt",
"location" : [ 9, 5, 9, 47 ],
"value" : {
"kind" : "ListExpr",
"location" : [ 9, 12, 9, 47 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"elements" : [ {
"kind" : "CallExpr",
"location" : [ 9, 13, 9, 22 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"function" : {
"kind" : "Identifier",
"location" : [ 9, 13, 9, 20 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "next_int"
},
"args" : [ ]
}, {
"kind" : "CallExpr",
"location" : [ 9, 25, 9, 34 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"function" : {
"kind" : "Identifier",
"location" : [ 9, 25, 9, 32 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "next_int"
},
"args" : [ ]
}, {
"kind" : "CallExpr",
"location" : [ 9, 37, 9, 46 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"function" : {
"kind" : "Identifier",
"location" : [ 9, 37, 9, 44 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "next_int"
},
"args" : [ ]
} ]
}
} ]
} ],
"statements" : [ {
"kind" : "ExprStmt",
"location" : [ 11, 1, 11, 34 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 11, 1, 11, 34 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
},
"function" : {
"kind" : "Identifier",
"location" : [ 11, 1, 11, 5 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
},
"name" : "print"
},
"args" : [ {
"kind" : "IndexExpr",
"location" : [ 11, 7, 11, 33 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"list" : {
"kind" : "CallExpr",
"location" : [ 11, 7, 11, 17 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"function" : {
"kind" : "Identifier",
"location" : [ 11, 7, 11, 15 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ ],
"returnType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
}
},
"name" : "make_list"
},
"args" : [ ]
},
"index" : {
"kind" : "BinaryExpr",
"location" : [ 11, 19, 11, 32 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"left" : {
"kind" : "CallExpr",
"location" : [ 11, 19, 11, 28 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"function" : {
"kind" : "Identifier",
"location" : [ 11, 19, 11, 26 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "next_int"
},
"args" : [ ]
},
"operator" : "-",
"right" : {
"kind" : "IntegerLiteral",
"location" : [ 11, 32, 11, 32 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 3
}
}
} ]
}
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}

@ -0,0 +1,3 @@
x:[int] = None
print(x[0])

@ -0,0 +1,96 @@
{
"kind" : "Program",
"location" : [ 1, 1, 3, 12 ],
"declarations" : [ {
"kind" : "VarDef",
"location" : [ 1, 1, 1, 14 ],
"var" : {
"kind" : "TypedVar",
"location" : [ 1, 1, 1, 7 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 1, 1, 1, 1 ],
"name" : "x"
},
"type" : {
"kind" : "ListType",
"location" : [ 1, 3, 1, 7 ],
"elementType" : {
"kind" : "ClassType",
"location" : [ 1, 4, 1, 6 ],
"className" : "int"
}
}
},
"value" : {
"kind" : "NoneLiteral",
"location" : [ 1, 11, 1, 14 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
}
} ],
"statements" : [ {
"kind" : "ExprStmt",
"location" : [ 3, 1, 3, 11 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 3, 1, 3, 11 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
},
"function" : {
"kind" : "Identifier",
"location" : [ 3, 1, 3, 5 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
},
"name" : "print"
},
"args" : [ {
"kind" : "IndexExpr",
"location" : [ 3, 7, 3, 10 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"list" : {
"kind" : "Identifier",
"location" : [ 3, 7, 3, 7 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "x"
},
"index" : {
"kind" : "IntegerLiteral",
"location" : [ 3, 9, 3, 9 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 0
}
} ]
}
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}

@ -0,0 +1,2 @@
Operation on None
Exited with error code 4

@ -0,0 +1,4 @@
x:[int] = None
x = [1, 2, 3]
print(x[-1])

@ -0,0 +1,156 @@
{
"kind" : "Program",
"location" : [ 1, 1, 4, 13 ],
"declarations" : [ {
"kind" : "VarDef",
"location" : [ 1, 1, 1, 14 ],
"var" : {
"kind" : "TypedVar",
"location" : [ 1, 1, 1, 7 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 1, 1, 1, 1 ],
"name" : "x"
},
"type" : {
"kind" : "ListType",
"location" : [ 1, 3, 1, 7 ],
"elementType" : {
"kind" : "ClassType",
"location" : [ 1, 4, 1, 6 ],
"className" : "int"
}
}
},
"value" : {
"kind" : "NoneLiteral",
"location" : [ 1, 11, 1, 14 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
}
} ],
"statements" : [ {
"kind" : "AssignStmt",
"location" : [ 3, 1, 3, 13 ],
"targets" : [ {
"kind" : "Identifier",
"location" : [ 3, 1, 3, 1 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "x"
} ],
"value" : {
"kind" : "ListExpr",
"location" : [ 3, 5, 3, 13 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"elements" : [ {
"kind" : "IntegerLiteral",
"location" : [ 3, 6, 3, 6 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 1
}, {
"kind" : "IntegerLiteral",
"location" : [ 3, 9, 3, 9 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 2
}, {
"kind" : "IntegerLiteral",
"location" : [ 3, 12, 3, 12 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 3
} ]
}
}, {
"kind" : "ExprStmt",
"location" : [ 4, 1, 4, 12 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 4, 1, 4, 12 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
},
"function" : {
"kind" : "Identifier",
"location" : [ 4, 1, 4, 5 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
},
"name" : "print"
},
"args" : [ {
"kind" : "IndexExpr",
"location" : [ 4, 7, 4, 11 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"list" : {
"kind" : "Identifier",
"location" : [ 4, 7, 4, 7 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "x"
},
"index" : {
"kind" : "UnaryExpr",
"location" : [ 4, 9, 4, 10 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"operator" : "-",
"operand" : {
"kind" : "IntegerLiteral",
"location" : [ 4, 10, 4, 10 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 1
}
}
} ]
}
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}

@ -0,0 +1,2 @@
Index out of bounds
Exited with error code 3

@ -0,0 +1,4 @@
x:[int] = None
x = [1, 2, 3]
print(x[3])

@ -0,0 +1,147 @@
{
"kind" : "Program",
"location" : [ 1, 1, 4, 12 ],
"declarations" : [ {
"kind" : "VarDef",
"location" : [ 1, 1, 1, 14 ],
"var" : {
"kind" : "TypedVar",
"location" : [ 1, 1, 1, 7 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 1, 1, 1, 1 ],
"name" : "x"
},
"type" : {
"kind" : "ListType",
"location" : [ 1, 3, 1, 7 ],
"elementType" : {
"kind" : "ClassType",
"location" : [ 1, 4, 1, 6 ],
"className" : "int"
}
}
},
"value" : {
"kind" : "NoneLiteral",
"location" : [ 1, 11, 1, 14 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
}
} ],
"statements" : [ {
"kind" : "AssignStmt",
"location" : [ 3, 1, 3, 13 ],
"targets" : [ {
"kind" : "Identifier",
"location" : [ 3, 1, 3, 1 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "x"
} ],
"value" : {
"kind" : "ListExpr",
"location" : [ 3, 5, 3, 13 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"elements" : [ {
"kind" : "IntegerLiteral",
"location" : [ 3, 6, 3, 6 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 1
}, {
"kind" : "IntegerLiteral",
"location" : [ 3, 9, 3, 9 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 2
}, {
"kind" : "IntegerLiteral",
"location" : [ 3, 12, 3, 12 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 3
} ]
}
}, {
"kind" : "ExprStmt",
"location" : [ 4, 1, 4, 11 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 4, 1, 4, 11 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
},
"function" : {
"kind" : "Identifier",
"location" : [ 4, 1, 4, 5 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
},
"name" : "print"
},
"args" : [ {
"kind" : "IndexExpr",
"location" : [ 4, 7, 4, 10 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"list" : {
"kind" : "Identifier",
"location" : [ 4, 7, 4, 7 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "x"
},
"index" : {
"kind" : "IntegerLiteral",
"location" : [ 4, 9, 4, 9 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 3
}
} ]
}
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}

@ -0,0 +1,2 @@
Index out of bounds
Exited with error code 3

@ -0,0 +1,4 @@
x:[int] = None
x = []
print(x[0])

@ -0,0 +1,120 @@
{
"kind" : "Program",
"location" : [ 1, 1, 4, 12 ],
"declarations" : [ {
"kind" : "VarDef",
"location" : [ 1, 1, 1, 14 ],
"var" : {
"kind" : "TypedVar",
"location" : [ 1, 1, 1, 7 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 1, 1, 1, 1 ],
"name" : "x"
},
"type" : {
"kind" : "ListType",
"location" : [ 1, 3, 1, 7 ],
"elementType" : {
"kind" : "ClassType",
"location" : [ 1, 4, 1, 6 ],
"className" : "int"
}
}
},
"value" : {
"kind" : "NoneLiteral",
"location" : [ 1, 11, 1, 14 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
}
} ],
"statements" : [ {
"kind" : "AssignStmt",
"location" : [ 3, 1, 3, 6 ],
"targets" : [ {
"kind" : "Identifier",
"location" : [ 3, 1, 3, 1 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "x"
} ],
"value" : {
"kind" : "ListExpr",
"location" : [ 3, 5, 3, 6 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<Empty>"
},
"elements" : [ ]
}
}, {
"kind" : "ExprStmt",
"location" : [ 4, 1, 4, 11 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 4, 1, 4, 11 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
},
"function" : {
"kind" : "Identifier",
"location" : [ 4, 1, 4, 5 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
},
"name" : "print"
},
"args" : [ {
"kind" : "IndexExpr",
"location" : [ 4, 7, 4, 10 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"list" : {
"kind" : "Identifier",
"location" : [ 4, 7, 4, 7 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "x"
},
"index" : {
"kind" : "IntegerLiteral",
"location" : [ 4, 9, 4, 9 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 0
}
} ]
}
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}

@ -0,0 +1,2 @@
Index out of bounds
Exited with error code 3

@ -0,0 +1,4 @@
x:[int] = None
x = [1, 2, 3]
print(len(x))

@ -0,0 +1,154 @@
{
"kind" : "Program",
"location" : [ 1, 1, 4, 14 ],
"declarations" : [ {
"kind" : "VarDef",
"location" : [ 1, 1, 1, 14 ],
"var" : {
"kind" : "TypedVar",
"location" : [ 1, 1, 1, 7 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 1, 1, 1, 1 ],
"name" : "x"
},
"type" : {
"kind" : "ListType",
"location" : [ 1, 3, 1, 7 ],
"elementType" : {
"kind" : "ClassType",
"location" : [ 1, 4, 1, 6 ],
"className" : "int"
}
}
},
"value" : {
"kind" : "NoneLiteral",
"location" : [ 1, 11, 1, 14 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
}
} ],
"statements" : [ {
"kind" : "AssignStmt",
"location" : [ 3, 1, 3, 13 ],
"targets" : [ {
"kind" : "Identifier",
"location" : [ 3, 1, 3, 1 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "x"
} ],
"value" : {
"kind" : "ListExpr",
"location" : [ 3, 5, 3, 13 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"elements" : [ {
"kind" : "IntegerLiteral",
"location" : [ 3, 6, 3, 6 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 1
}, {
"kind" : "IntegerLiteral",
"location" : [ 3, 9, 3, 9 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 2
}, {
"kind" : "IntegerLiteral",
"location" : [ 3, 12, 3, 12 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 3
} ]
}
}, {
"kind" : "ExprStmt",
"location" : [ 4, 1, 4, 13 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 4, 1, 4, 13 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
},
"function" : {
"kind" : "Identifier",
"location" : [ 4, 1, 4, 5 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
},
"name" : "print"
},
"args" : [ {
"kind" : "CallExpr",
"location" : [ 4, 7, 4, 12 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"function" : {
"kind" : "Identifier",
"location" : [ 4, 7, 4, 9 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "len"
},
"args" : [ {
"kind" : "Identifier",
"location" : [ 4, 11, 4, 11 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "x"
} ]
} ]
}
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}

@ -0,0 +1,4 @@
x:[int] = None
x = []
print(len(x))

@ -0,0 +1,127 @@
{
"kind" : "Program",
"location" : [ 1, 1, 4, 14 ],
"declarations" : [ {
"kind" : "VarDef",
"location" : [ 1, 1, 1, 14 ],
"var" : {
"kind" : "TypedVar",
"location" : [ 1, 1, 1, 7 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 1, 1, 1, 1 ],
"name" : "x"
},
"type" : {
"kind" : "ListType",
"location" : [ 1, 3, 1, 7 ],
"elementType" : {
"kind" : "ClassType",
"location" : [ 1, 4, 1, 6 ],
"className" : "int"
}
}
},
"value" : {
"kind" : "NoneLiteral",
"location" : [ 1, 11, 1, 14 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
}
} ],
"statements" : [ {
"kind" : "AssignStmt",
"location" : [ 3, 1, 3, 6 ],
"targets" : [ {
"kind" : "Identifier",
"location" : [ 3, 1, 3, 1 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "x"
} ],
"value" : {
"kind" : "ListExpr",
"location" : [ 3, 5, 3, 6 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<Empty>"
},
"elements" : [ ]
}
}, {
"kind" : "ExprStmt",
"location" : [ 4, 1, 4, 13 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 4, 1, 4, 13 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
},
"function" : {
"kind" : "Identifier",
"location" : [ 4, 1, 4, 5 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
},
"name" : "print"
},
"args" : [ {
"kind" : "CallExpr",
"location" : [ 4, 7, 4, 12 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"function" : {
"kind" : "Identifier",
"location" : [ 4, 7, 4, 9 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "len"
},
"args" : [ {
"kind" : "Identifier",
"location" : [ 4, 11, 4, 11 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "x"
} ]
} ]
}
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}

@ -0,0 +1,9 @@
x:[int] = None
x = [1, 2, 3]
x[0] = 4
x[1] = 5
x[2] = 6
print(x[0])
print(x[1])
print(x[2])

@ -0,0 +1,382 @@
{
"kind" : "Program",
"location" : [ 1, 1, 9, 12 ],
"declarations" : [ {
"kind" : "VarDef",
"location" : [ 1, 1, 1, 14 ],
"var" : {
"kind" : "TypedVar",
"location" : [ 1, 1, 1, 7 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 1, 1, 1, 1 ],
"name" : "x"
},
"type" : {
"kind" : "ListType",
"location" : [ 1, 3, 1, 7 ],
"elementType" : {
"kind" : "ClassType",
"location" : [ 1, 4, 1, 6 ],
"className" : "int"
}
}
},
"value" : {
"kind" : "NoneLiteral",
"location" : [ 1, 11, 1, 14 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
}
} ],
"statements" : [ {
"kind" : "AssignStmt",
"location" : [ 3, 1, 3, 13 ],
"targets" : [ {
"kind" : "Identifier",
"location" : [ 3, 1, 3, 1 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "x"
} ],
"value" : {
"kind" : "ListExpr",
"location" : [ 3, 5, 3, 13 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"elements" : [ {
"kind" : "IntegerLiteral",
"location" : [ 3, 6, 3, 6 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 1
}, {
"kind" : "IntegerLiteral",
"location" : [ 3, 9, 3, 9 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 2
}, {
"kind" : "IntegerLiteral",
"location" : [ 3, 12, 3, 12 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 3
} ]
}
}, {
"kind" : "AssignStmt",
"location" : [ 4, 1, 4, 8 ],
"targets" : [ {
"kind" : "IndexExpr",
"location" : [ 4, 1, 4, 4 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"list" : {
"kind" : "Identifier",
"location" : [ 4, 1, 4, 1 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "x"
},
"index" : {
"kind" : "IntegerLiteral",
"location" : [ 4, 3, 4, 3 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 0
}
} ],
"value" : {
"kind" : "IntegerLiteral",
"location" : [ 4, 8, 4, 8 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 4
}
}, {
"kind" : "AssignStmt",
"location" : [ 5, 1, 5, 8 ],
"targets" : [ {
"kind" : "IndexExpr",
"location" : [ 5, 1, 5, 4 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"list" : {
"kind" : "Identifier",
"location" : [ 5, 1, 5, 1 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "x"
},
"index" : {
"kind" : "IntegerLiteral",
"location" : [ 5, 3, 5, 3 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 1
}
} ],
"value" : {
"kind" : "IntegerLiteral",
"location" : [ 5, 8, 5, 8 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 5
}
}, {
"kind" : "AssignStmt",
"location" : [ 6, 1, 6, 8 ],
"targets" : [ {
"kind" : "IndexExpr",
"location" : [ 6, 1, 6, 4 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"list" : {
"kind" : "Identifier",
"location" : [ 6, 1, 6, 1 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "x"
},
"index" : {
"kind" : "IntegerLiteral",
"location" : [ 6, 3, 6, 3 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 2
}
} ],
"value" : {
"kind" : "IntegerLiteral",
"location" : [ 6, 8, 6, 8 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 6
}
}, {
"kind" : "ExprStmt",
"location" : [ 7, 1, 7, 11 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 7, 1, 7, 11 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
},
"function" : {
"kind" : "Identifier",
"location" : [ 7, 1, 7, 5 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
},
"name" : "print"
},
"args" : [ {
"kind" : "IndexExpr",
"location" : [ 7, 7, 7, 10 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"list" : {
"kind" : "Identifier",
"location" : [ 7, 7, 7, 7 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "x"
},
"index" : {
"kind" : "IntegerLiteral",
"location" : [ 7, 9, 7, 9 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 0
}
} ]
}
}, {
"kind" : "ExprStmt",
"location" : [ 8, 1, 8, 11 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 8, 1, 8, 11 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
},
"function" : {
"kind" : "Identifier",
"location" : [ 8, 1, 8, 5 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
},
"name" : "print"
},
"args" : [ {
"kind" : "IndexExpr",
"location" : [ 8, 7, 8, 10 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"list" : {
"kind" : "Identifier",
"location" : [ 8, 7, 8, 7 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "x"
},
"index" : {
"kind" : "IntegerLiteral",
"location" : [ 8, 9, 8, 9 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 1
}
} ]
}
}, {
"kind" : "ExprStmt",
"location" : [ 9, 1, 9, 11 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 9, 1, 9, 11 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
},
"function" : {
"kind" : "Identifier",
"location" : [ 9, 1, 9, 5 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
},
"name" : "print"
},
"args" : [ {
"kind" : "IndexExpr",
"location" : [ 9, 7, 9, 10 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"list" : {
"kind" : "Identifier",
"location" : [ 9, 7, 9, 7 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "x"
},
"index" : {
"kind" : "IntegerLiteral",
"location" : [ 9, 9, 9, 9 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 2
}
} ]
}
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}

@ -0,0 +1,4 @@
x:[int] = None
x[0] = 1

@ -0,0 +1,81 @@
{
"kind" : "Program",
"location" : [ 1, 1, 3, 9 ],
"declarations" : [ {
"kind" : "VarDef",
"location" : [ 1, 1, 1, 14 ],
"var" : {
"kind" : "TypedVar",
"location" : [ 1, 1, 1, 7 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 1, 1, 1, 1 ],
"name" : "x"
},
"type" : {
"kind" : "ListType",
"location" : [ 1, 3, 1, 7 ],
"elementType" : {
"kind" : "ClassType",
"location" : [ 1, 4, 1, 6 ],
"className" : "int"
}
}
},
"value" : {
"kind" : "NoneLiteral",
"location" : [ 1, 11, 1, 14 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
}
} ],
"statements" : [ {
"kind" : "AssignStmt",
"location" : [ 3, 1, 3, 8 ],
"targets" : [ {
"kind" : "IndexExpr",
"location" : [ 3, 1, 3, 4 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"list" : {
"kind" : "Identifier",
"location" : [ 3, 1, 3, 1 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "x"
},
"index" : {
"kind" : "IntegerLiteral",
"location" : [ 3, 3, 3, 3 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 0
}
} ],
"value" : {
"kind" : "IntegerLiteral",
"location" : [ 3, 8, 3, 8 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 1
}
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}

@ -0,0 +1,2 @@
Operation on None
Exited with error code 4

@ -0,0 +1,7 @@
x:[int] = None
x = [1, 2, 3]
x[-1] = 4
print(x[0])
print(x[1])
print(x[2])

@ -0,0 +1,309 @@
{
"kind" : "Program",
"location" : [ 1, 1, 7, 12 ],
"declarations" : [ {
"kind" : "VarDef",
"location" : [ 1, 1, 1, 14 ],
"var" : {
"kind" : "TypedVar",
"location" : [ 1, 1, 1, 7 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 1, 1, 1, 1 ],
"name" : "x"
},
"type" : {
"kind" : "ListType",
"location" : [ 1, 3, 1, 7 ],
"elementType" : {
"kind" : "ClassType",
"location" : [ 1, 4, 1, 6 ],
"className" : "int"
}
}
},
"value" : {
"kind" : "NoneLiteral",
"location" : [ 1, 11, 1, 14 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
}
} ],
"statements" : [ {
"kind" : "AssignStmt",
"location" : [ 3, 1, 3, 13 ],
"targets" : [ {
"kind" : "Identifier",
"location" : [ 3, 1, 3, 1 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "x"
} ],
"value" : {
"kind" : "ListExpr",
"location" : [ 3, 5, 3, 13 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"elements" : [ {
"kind" : "IntegerLiteral",
"location" : [ 3, 6, 3, 6 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 1
}, {
"kind" : "IntegerLiteral",
"location" : [ 3, 9, 3, 9 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 2
}, {
"kind" : "IntegerLiteral",
"location" : [ 3, 12, 3, 12 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 3
} ]
}
}, {
"kind" : "AssignStmt",
"location" : [ 4, 1, 4, 9 ],
"targets" : [ {
"kind" : "IndexExpr",
"location" : [ 4, 1, 4, 5 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"list" : {
"kind" : "Identifier",
"location" : [ 4, 1, 4, 1 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "x"
},
"index" : {
"kind" : "UnaryExpr",
"location" : [ 4, 3, 4, 4 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"operator" : "-",
"operand" : {
"kind" : "IntegerLiteral",
"location" : [ 4, 4, 4, 4 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 1
}
}
} ],
"value" : {
"kind" : "IntegerLiteral",
"location" : [ 4, 9, 4, 9 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 4
}
}, {
"kind" : "ExprStmt",
"location" : [ 5, 1, 5, 11 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 5, 1, 5, 11 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
},
"function" : {
"kind" : "Identifier",
"location" : [ 5, 1, 5, 5 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
},
"name" : "print"
},
"args" : [ {
"kind" : "IndexExpr",
"location" : [ 5, 7, 5, 10 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"list" : {
"kind" : "Identifier",
"location" : [ 5, 7, 5, 7 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "x"
},
"index" : {
"kind" : "IntegerLiteral",
"location" : [ 5, 9, 5, 9 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 0
}
} ]
}
}, {
"kind" : "ExprStmt",
"location" : [ 6, 1, 6, 11 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 6, 1, 6, 11 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
},
"function" : {
"kind" : "Identifier",
"location" : [ 6, 1, 6, 5 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
},
"name" : "print"
},
"args" : [ {
"kind" : "IndexExpr",
"location" : [ 6, 7, 6, 10 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"list" : {
"kind" : "Identifier",
"location" : [ 6, 7, 6, 7 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "x"
},
"index" : {
"kind" : "IntegerLiteral",
"location" : [ 6, 9, 6, 9 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 1
}
} ]
}
}, {
"kind" : "ExprStmt",
"location" : [ 7, 1, 7, 11 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 7, 1, 7, 11 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
},
"function" : {
"kind" : "Identifier",
"location" : [ 7, 1, 7, 5 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
},
"name" : "print"
},
"args" : [ {
"kind" : "IndexExpr",
"location" : [ 7, 7, 7, 10 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"list" : {
"kind" : "Identifier",
"location" : [ 7, 7, 7, 7 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "x"
},
"index" : {
"kind" : "IntegerLiteral",
"location" : [ 7, 9, 7, 9 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 2
}
} ]
}
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}

@ -0,0 +1,2 @@
Index out of bounds
Exited with error code 3

@ -0,0 +1,7 @@
x:[int] = None
x = [1, 2, 3]
x[4] = 4
print(x[0])
print(x[1])
print(x[2])

@ -0,0 +1,300 @@
{
"kind" : "Program",
"location" : [ 1, 1, 7, 12 ],
"declarations" : [ {
"kind" : "VarDef",
"location" : [ 1, 1, 1, 14 ],
"var" : {
"kind" : "TypedVar",
"location" : [ 1, 1, 1, 7 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 1, 1, 1, 1 ],
"name" : "x"
},
"type" : {
"kind" : "ListType",
"location" : [ 1, 3, 1, 7 ],
"elementType" : {
"kind" : "ClassType",
"location" : [ 1, 4, 1, 6 ],
"className" : "int"
}
}
},
"value" : {
"kind" : "NoneLiteral",
"location" : [ 1, 11, 1, 14 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
}
} ],
"statements" : [ {
"kind" : "AssignStmt",
"location" : [ 3, 1, 3, 13 ],
"targets" : [ {
"kind" : "Identifier",
"location" : [ 3, 1, 3, 1 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "x"
} ],
"value" : {
"kind" : "ListExpr",
"location" : [ 3, 5, 3, 13 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"elements" : [ {
"kind" : "IntegerLiteral",
"location" : [ 3, 6, 3, 6 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 1
}, {
"kind" : "IntegerLiteral",
"location" : [ 3, 9, 3, 9 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 2
}, {
"kind" : "IntegerLiteral",
"location" : [ 3, 12, 3, 12 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 3
} ]
}
}, {
"kind" : "AssignStmt",
"location" : [ 4, 1, 4, 8 ],
"targets" : [ {
"kind" : "IndexExpr",
"location" : [ 4, 1, 4, 4 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"list" : {
"kind" : "Identifier",
"location" : [ 4, 1, 4, 1 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "x"
},
"index" : {
"kind" : "IntegerLiteral",
"location" : [ 4, 3, 4, 3 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 4
}
} ],
"value" : {
"kind" : "IntegerLiteral",
"location" : [ 4, 8, 4, 8 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 4
}
}, {
"kind" : "ExprStmt",
"location" : [ 5, 1, 5, 11 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 5, 1, 5, 11 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
},
"function" : {
"kind" : "Identifier",
"location" : [ 5, 1, 5, 5 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
},
"name" : "print"
},
"args" : [ {
"kind" : "IndexExpr",
"location" : [ 5, 7, 5, 10 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"list" : {
"kind" : "Identifier",
"location" : [ 5, 7, 5, 7 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "x"
},
"index" : {
"kind" : "IntegerLiteral",
"location" : [ 5, 9, 5, 9 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 0
}
} ]
}
}, {
"kind" : "ExprStmt",
"location" : [ 6, 1, 6, 11 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 6, 1, 6, 11 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
},
"function" : {
"kind" : "Identifier",
"location" : [ 6, 1, 6, 5 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
},
"name" : "print"
},
"args" : [ {
"kind" : "IndexExpr",
"location" : [ 6, 7, 6, 10 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"list" : {
"kind" : "Identifier",
"location" : [ 6, 7, 6, 7 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "x"
},
"index" : {
"kind" : "IntegerLiteral",
"location" : [ 6, 9, 6, 9 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 1
}
} ]
}
}, {
"kind" : "ExprStmt",
"location" : [ 7, 1, 7, 11 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 7, 1, 7, 11 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
},
"function" : {
"kind" : "Identifier",
"location" : [ 7, 1, 7, 5 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "object"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
},
"name" : "print"
},
"args" : [ {
"kind" : "IndexExpr",
"location" : [ 7, 7, 7, 10 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"list" : {
"kind" : "Identifier",
"location" : [ 7, 7, 7, 7 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "x"
},
"index" : {
"kind" : "IntegerLiteral",
"location" : [ 7, 9, 7, 9 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 2
}
} ]
}
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}

@ -0,0 +1,2 @@
Index out of bounds
Exited with error code 3

@ -0,0 +1,4 @@
x:[int] = None
x = []
x[0] = 4

@ -0,0 +1,105 @@
{
"kind" : "Program",
"location" : [ 1, 1, 4, 9 ],
"declarations" : [ {
"kind" : "VarDef",
"location" : [ 1, 1, 1, 14 ],
"var" : {
"kind" : "TypedVar",
"location" : [ 1, 1, 1, 7 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 1, 1, 1, 1 ],
"name" : "x"
},
"type" : {
"kind" : "ListType",
"location" : [ 1, 3, 1, 7 ],
"elementType" : {
"kind" : "ClassType",
"location" : [ 1, 4, 1, 6 ],
"className" : "int"
}
}
},
"value" : {
"kind" : "NoneLiteral",
"location" : [ 1, 11, 1, 14 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
}
} ],
"statements" : [ {
"kind" : "AssignStmt",
"location" : [ 3, 1, 3, 6 ],
"targets" : [ {
"kind" : "Identifier",
"location" : [ 3, 1, 3, 1 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "x"
} ],
"value" : {
"kind" : "ListExpr",
"location" : [ 3, 5, 3, 6 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<Empty>"
},
"elements" : [ ]
}
}, {
"kind" : "AssignStmt",
"location" : [ 4, 1, 4, 8 ],
"targets" : [ {
"kind" : "IndexExpr",
"location" : [ 4, 1, 4, 4 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"list" : {
"kind" : "Identifier",
"location" : [ 4, 1, 4, 1 ],
"inferredType" : {
"kind" : "ListValueType",
"elementType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "x"
},
"index" : {
"kind" : "IntegerLiteral",
"location" : [ 4, 3, 4, 3 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 0
}
} ],
"value" : {
"kind" : "IntegerLiteral",
"location" : [ 4, 8, 4, 8 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 4
}
} ],
"errors" : {
"errors" : [ ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save