commit
81d67b9622
@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
./build.sh
|
||||
./test_sample.sh
|
||||
./test_benchmarks.sh
|
@ -0,0 +1,32 @@
|
||||
## Grading
|
||||
|
||||
Core Tests: 59/59
|
||||
|
||||
Extra: 21/21
|
||||
|
||||
=========================
|
||||
|
||||
Standard tests: 80/80
|
||||
|
||||
Work Log: 10/10
|
||||
|
||||
Additional Tests: 10/10
|
||||
|
||||
Code style: 10/10
|
||||
|
||||
Improvements: +1
|
||||
|
||||
Overall: 111/110
|
||||
|
||||
Congratulations! Your analyzer has solved every test case correctly again. Your improvement is solid and easy to verify. The two-passes design is clear and direct.
|
||||
|
||||
## Testing
|
||||
|
||||
The additional test cases provided in the `student_contributed` directory are carefully selected and well structured. I am surprised that you managed to reproduce those error messages from reference-implementation. Some of them are weird and probably not worth reproducing, but thanks for reducing the workload on my end.
|
||||
|
||||
## Miscellaneous
|
||||
The Code structure is clear and consistent but could still be improved by removing commented codes (at least in the final version).
|
||||
|
||||
The automatic test shell scripts are very helpful. It would be even better if you could organize them with CI tools like travis.ci or gitflow. It is totally optional but it would be fun to construct a CI pipeline.
|
||||
|
||||
The worklog contains some typos that could be avoided by adding a spellchecker to the IDE or CI.
|
@ -0,0 +1,24 @@
|
||||
# Tests for PA1: ChocoPy Parser
|
||||
|
||||
Clone a student repository:
|
||||
```
|
||||
TEAM="team"
|
||||
git clone --branch=pa1final \
|
||||
https://github.com/nyu-compiler-construction/pa1-chocopy-parser-${TEAM}
|
||||
```
|
||||
|
||||
Build it:
|
||||
```
|
||||
cd pa1-chocopy-parser-${TEAM}
|
||||
mvn clean package
|
||||
```
|
||||
|
||||
Clone the tests _into_ the student repository:
|
||||
```
|
||||
git clone https://github.com/nyu-compiler-construction/pa1-tests
|
||||
```
|
||||
|
||||
Run the tests:
|
||||
```
|
||||
./pa1-tests/run-tests.sh
|
||||
```
|
Binary file not shown.
@ -0,0 +1 @@
|
||||
x = (y = 2)
|
@ -0,0 +1,16 @@
|
||||
{
|
||||
"kind" : "Program",
|
||||
"location" : [ 1, 6, 1, 6 ],
|
||||
"declarations" : [ ],
|
||||
"statements" : [ ],
|
||||
"errors" : {
|
||||
"errors" : [ {
|
||||
"kind" : "CompilerError",
|
||||
"location" : [ 1, 8, 1, 8 ],
|
||||
"message" : "Parse error near token EQ: =",
|
||||
"syntax" : true
|
||||
} ],
|
||||
"kind" : "Errors",
|
||||
"location" : [ 0, 0, 0, 0 ]
|
||||
}
|
||||
}
|
@ -0,0 +1 @@
|
||||
print(x = 1)
|
@ -0,0 +1,16 @@
|
||||
{
|
||||
"kind" : "Program",
|
||||
"location" : [ 1, 7, 1, 7 ],
|
||||
"declarations" : [ ],
|
||||
"statements" : [ ],
|
||||
"errors" : {
|
||||
"errors" : [ {
|
||||
"kind" : "CompilerError",
|
||||
"location" : [ 1, 9, 1, 9 ],
|
||||
"message" : "Parse error near token EQ: =",
|
||||
"syntax" : true
|
||||
} ],
|
||||
"kind" : "Errors",
|
||||
"location" : [ 0, 0, 0, 0 ]
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
def foo(a, b) -> 1:
|
||||
x:int = a
|
||||
return 1
|
||||
|
||||
print(1)
|
||||
print(3**6)
|
@ -0,0 +1,64 @@
|
||||
{
|
||||
"kind" : "Program",
|
||||
"location" : [ 2, 13, 6, 8 ],
|
||||
"declarations" : [ ],
|
||||
"statements" : [ {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 2, 13, 2, 13 ],
|
||||
"expr" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 2, 13, 2, 13 ],
|
||||
"name" : "a"
|
||||
}
|
||||
}, {
|
||||
"kind" : "ReturnStmt",
|
||||
"location" : [ 3, 5, 3, 12 ],
|
||||
"value" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 3, 12, 3, 12 ],
|
||||
"value" : 1
|
||||
}
|
||||
}, {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 5, 1, 5, 8 ],
|
||||
"expr" : {
|
||||
"kind" : "CallExpr",
|
||||
"location" : [ 5, 1, 5, 8 ],
|
||||
"function" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 5, 1, 5, 5 ],
|
||||
"name" : "print"
|
||||
},
|
||||
"args" : [ {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 5, 7, 5, 7 ],
|
||||
"value" : 1
|
||||
} ]
|
||||
}
|
||||
} ],
|
||||
"errors" : {
|
||||
"errors" : [ {
|
||||
"kind" : "CompilerError",
|
||||
"location" : [ 1, 10, 1, 10 ],
|
||||
"message" : "Parse error near token COMMA: ,",
|
||||
"syntax" : true
|
||||
}, {
|
||||
"kind" : "CompilerError",
|
||||
"location" : [ 2, 13, 2, 13 ],
|
||||
"message" : "Parse error near token IDENTIFIER: a",
|
||||
"syntax" : true
|
||||
}, {
|
||||
"kind" : "CompilerError",
|
||||
"location" : [ 5, 1, 5, 0 ],
|
||||
"message" : "Parse error near token DEDENT: ",
|
||||
"syntax" : true
|
||||
}, {
|
||||
"kind" : "CompilerError",
|
||||
"location" : [ 6, 9, 6, 9 ],
|
||||
"message" : "Parse error near token TIMES: *",
|
||||
"syntax" : true
|
||||
} ],
|
||||
"kind" : "Errors",
|
||||
"location" : [ 0, 0, 0, 0 ]
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
x = 1
|
||||
y = 2
|
||||
z = 3
|
@ -0,0 +1,47 @@
|
||||
{
|
||||
"kind" : "Program",
|
||||
"location" : [ 2, 3, 3, 6 ],
|
||||
"declarations" : [ ],
|
||||
"statements" : [ {
|
||||
"kind" : "AssignStmt",
|
||||
"location" : [ 2, 3, 2, 7 ],
|
||||
"targets" : [ {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 2, 3, 2, 3 ],
|
||||
"name" : "y"
|
||||
} ],
|
||||
"value" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 2, 7, 2, 7 ],
|
||||
"value" : 2
|
||||
}
|
||||
}, {
|
||||
"kind" : "AssignStmt",
|
||||
"location" : [ 3, 1, 3, 5 ],
|
||||
"targets" : [ {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 3, 1, 3, 1 ],
|
||||
"name" : "z"
|
||||
} ],
|
||||
"value" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 3, 5, 3, 5 ],
|
||||
"value" : 3
|
||||
}
|
||||
} ],
|
||||
"errors" : {
|
||||
"errors" : [ {
|
||||
"kind" : "CompilerError",
|
||||
"location" : [ 2, 1, 2, 2 ],
|
||||
"message" : "Parse error near token INDENT: ",
|
||||
"syntax" : true
|
||||
}, {
|
||||
"kind" : "CompilerError",
|
||||
"location" : [ 3, 1, 3, 0 ],
|
||||
"message" : "Parse error near token DEDENT: ",
|
||||
"syntax" : true
|
||||
} ],
|
||||
"kind" : "Errors",
|
||||
"location" : [ 0, 0, 0, 0 ]
|
||||
}
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
1 + 2
|
||||
3 == 4 or (not False && True)
|
||||
5 + 6
|
||||
7 << 8
|
@ -0,0 +1,65 @@
|
||||
{
|
||||
"kind" : "Program",
|
||||
"location" : [ 1, 1, 4, 7 ],
|
||||
"declarations" : [ ],
|
||||
"statements" : [ {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 1, 1, 1, 5 ],
|
||||
"expr" : {
|
||||
"kind" : "BinaryExpr",
|
||||
"location" : [ 1, 1, 1, 5 ],
|
||||
"left" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 1, 1, 1, 1 ],
|
||||
"value" : 1
|
||||
},
|
||||
"operator" : "+",
|
||||
"right" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 1, 5, 1, 5 ],
|
||||
"value" : 2
|
||||
}
|
||||
}
|
||||
}, {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 3, 1, 3, 5 ],
|
||||
"expr" : {
|
||||
"kind" : "BinaryExpr",
|
||||
"location" : [ 3, 1, 3, 5 ],
|
||||
"left" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 3, 1, 3, 1 ],
|
||||
"value" : 5
|
||||
},
|
||||
"operator" : "+",
|
||||
"right" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 3, 5, 3, 5 ],
|
||||
"value" : 6
|
||||
}
|
||||
}
|
||||
}, {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 4, 6, 4, 6 ],
|
||||
"expr" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 4, 6, 4, 6 ],
|
||||
"value" : 8
|
||||
}
|
||||
} ],
|
||||
"errors" : {
|
||||
"errors" : [ {
|
||||
"kind" : "CompilerError",
|
||||
"location" : [ 2, 22, 2, 22 ],
|
||||
"message" : "Parse error near token UNRECOGNIZED: &",
|
||||
"syntax" : true
|
||||
}, {
|
||||
"kind" : "CompilerError",
|
||||
"location" : [ 4, 4, 4, 4 ],
|
||||
"message" : "Parse error near token LT: <",
|
||||
"syntax" : true
|
||||
} ],
|
||||
"kind" : "Errors",
|
||||
"location" : [ 0, 0, 0, 0 ]
|
||||
}
|
||||
}
|
@ -0,0 +1,2 @@
|
||||
x[0] = y = z.f = 1
|
||||
z.g = y = x[0]
|
@ -0,0 +1,85 @@
|
||||
{
|
||||
"kind" : "Program",
|
||||
"location" : [ 1, 1, 2, 15 ],
|
||||
"declarations" : [ ],
|
||||
"statements" : [ {
|
||||
"kind" : "AssignStmt",
|
||||
"location" : [ 1, 1, 1, 18 ],
|
||||
"targets" : [ {
|
||||
"kind" : "IndexExpr",
|
||||
"location" : [ 1, 1, 1, 4 ],
|
||||
"list" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 1, 1, 1, 1 ],
|
||||
"name" : "x"
|
||||
},
|
||||
"index" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 1, 3, 1, 3 ],
|
||||
"value" : 0
|
||||
}
|
||||
}, {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 1, 8, 1, 8 ],
|
||||
"name" : "y"
|
||||
}, {
|
||||
"kind" : "MemberExpr",
|
||||
"location" : [ 1, 12, 1, 14 ],
|
||||
"object" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 1, 12, 1, 12 ],
|
||||
"name" : "z"
|
||||
},
|
||||
"member" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 1, 14, 1, 14 ],
|
||||
"name" : "f"
|
||||
}
|
||||
} ],
|
||||
"value" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 1, 18, 1, 18 ],
|
||||
"value" : 1
|
||||
}
|
||||
}, {
|
||||
"kind" : "AssignStmt",
|
||||
"location" : [ 2, 1, 2, 14 ],
|
||||
"targets" : [ {
|
||||
"kind" : "MemberExpr",
|
||||
"location" : [ 2, 1, 2, 3 ],
|
||||
"object" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 2, 1, 2, 1 ],
|
||||
"name" : "z"
|
||||
},
|
||||
"member" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 2, 3, 2, 3 ],
|
||||
"name" : "g"
|
||||
}
|
||||
}, {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 2, 7, 2, 7 ],
|
||||
"name" : "y"
|
||||
} ],
|
||||
"value" : {
|
||||
"kind" : "IndexExpr",
|
||||
"location" : [ 2, 11, 2, 14 ],
|
||||
"list" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 2, 11, 2, 11 ],
|
||||
"name" : "x"
|
||||
},
|
||||
"index" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 2, 13, 2, 13 ],
|
||||
"value" : 0
|
||||
}
|
||||
}
|
||||
} ],
|
||||
"errors" : {
|
||||
"errors" : [ ],
|
||||
"kind" : "Errors",
|
||||
"location" : [ 0, 0, 0, 0 ]
|
||||
}
|
||||
}
|
@ -0,0 +1 @@
|
||||
x = y = z = 1
|
@ -0,0 +1,32 @@
|
||||
{
|
||||
"kind" : "Program",
|
||||
"location" : [ 1, 1, 1, 14 ],
|
||||
"declarations" : [ ],
|
||||
"statements" : [ {
|
||||
"kind" : "AssignStmt",
|
||||
"location" : [ 1, 1, 1, 13 ],
|
||||
"targets" : [ {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 1, 1, 1, 1 ],
|
||||
"name" : "x"
|
||||
}, {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 1, 5, 1, 5 ],
|
||||
"name" : "y"
|
||||
}, {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 1, 9, 1, 9 ],
|
||||
"name" : "z"
|
||||
} ],
|
||||
"value" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 1, 13, 1, 13 ],
|
||||
"value" : 1
|
||||
}
|
||||
} ],
|
||||
"errors" : {
|
||||
"errors" : [ ],
|
||||
"kind" : "Errors",
|
||||
"location" : [ 0, 0, 0, 0 ]
|
||||
}
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
class Foo(object):
|
||||
x:int = 1
|
||||
|
||||
f = Foo()
|
@ -0,0 +1,65 @@
|
||||
{
|
||||
"kind" : "Program",
|
||||
"location" : [ 1, 1, 4, 10 ],
|
||||
"declarations" : [ {
|
||||
"kind" : "ClassDef",
|
||||
"location" : [ 1, 1, 2, 14 ],
|
||||
"name" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 1, 7, 1, 9 ],
|
||||
"name" : "Foo"
|
||||
},
|
||||
"superClass" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 1, 11, 1, 16 ],
|
||||
"name" : "object"
|
||||
},
|
||||
"declarations" : [ {
|
||||
"kind" : "VarDef",
|
||||
"location" : [ 2, 5, 2, 13 ],
|
||||
"var" : {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 2, 5, 2, 9 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 2, 5, 2, 5 ],
|
||||
"name" : "x"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 2, 7, 2, 9 ],
|
||||
"className" : "int"
|
||||
}
|
||||
},
|
||||
"value" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 2, 13, 2, 13 ],
|
||||
"value" : 1
|
||||
}
|
||||
} ]
|
||||
} ],
|
||||
"statements" : [ {
|
||||
"kind" : "AssignStmt",
|
||||
"location" : [ 4, 1, 4, 9 ],
|
||||
"targets" : [ {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 4, 1, 4, 1 ],
|
||||
"name" : "f"
|
||||
} ],
|
||||
"value" : {
|
||||
"kind" : "CallExpr",
|
||||
"location" : [ 4, 5, 4, 9 ],
|
||||
"function" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 4, 5, 4, 7 ],
|
||||
"name" : "Foo"
|
||||
},
|
||||
"args" : [ ]
|
||||
}
|
||||
} ],
|
||||
"errors" : {
|
||||
"errors" : [ ],
|
||||
"kind" : "Errors",
|
||||
"location" : [ 0, 0, 0, 0 ]
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
class Foo(object):
|
||||
x:int = 1
|
||||
|
||||
f = Foo()
|
||||
print(f.x)
|
@ -0,0 +1,91 @@
|
||||
{
|
||||
"kind" : "Program",
|
||||
"location" : [ 1, 1, 5, 11 ],
|
||||
"declarations" : [ {
|
||||
"kind" : "ClassDef",
|
||||
"location" : [ 1, 1, 2, 14 ],
|
||||
"name" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 1, 7, 1, 9 ],
|
||||
"name" : "Foo"
|
||||
},
|
||||
"superClass" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 1, 11, 1, 16 ],
|
||||
"name" : "object"
|
||||
},
|
||||
"declarations" : [ {
|
||||
"kind" : "VarDef",
|
||||
"location" : [ 2, 5, 2, 13 ],
|
||||
"var" : {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 2, 5, 2, 9 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 2, 5, 2, 5 ],
|
||||
"name" : "x"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 2, 7, 2, 9 ],
|
||||
"className" : "int"
|
||||
}
|
||||
},
|
||||
"value" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 2, 13, 2, 13 ],
|
||||
"value" : 1
|
||||
}
|
||||
} ]
|
||||
} ],
|
||||
"statements" : [ {
|
||||
"kind" : "AssignStmt",
|
||||
"location" : [ 4, 1, 4, 9 ],
|
||||
"targets" : [ {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 4, 1, 4, 1 ],
|
||||
"name" : "f"
|
||||
} ],
|
||||
"value" : {
|
||||
"kind" : "CallExpr",
|
||||
"location" : [ 4, 5, 4, 9 ],
|
||||
"function" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 4, 5, 4, 7 ],
|
||||
"name" : "Foo"
|
||||
},
|
||||
"args" : [ ]
|
||||
}
|
||||
}, {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 5, 1, 5, 10 ],
|
||||
"expr" : {
|
||||
"kind" : "CallExpr",
|
||||
"location" : [ 5, 1, 5, 10 ],
|
||||
"function" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 5, 1, 5, 5 ],
|
||||
"name" : "print"
|
||||
},
|
||||
"args" : [ {
|
||||
"kind" : "MemberExpr",
|
||||
"location" : [ 5, 7, 5, 9 ],
|
||||
"object" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 5, 7, 5, 7 ],
|
||||
"name" : "f"
|
||||
},
|
||||
"member" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 5, 9, 5, 9 ],
|
||||
"name" : "x"
|
||||
}
|
||||
} ]
|
||||
}
|
||||
} ],
|
||||
"errors" : {
|
||||
"errors" : [ ],
|
||||
"kind" : "Errors",
|
||||
"location" : [ 0, 0, 0, 0 ]
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
class Foo(object):
|
||||
x:int = 1
|
||||
|
||||
f = Foo()
|
||||
f.x = 2
|
@ -0,0 +1,87 @@
|
||||
{
|
||||
"kind" : "Program",
|
||||
"location" : [ 1, 1, 5, 8 ],
|
||||
"declarations" : [ {
|
||||
"kind" : "ClassDef",
|
||||
"location" : [ 1, 1, 2, 14 ],
|
||||
"name" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 1, 7, 1, 9 ],
|
||||
"name" : "Foo"
|
||||
},
|
||||
"superClass" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 1, 11, 1, 16 ],
|
||||
"name" : "object"
|
||||
},
|
||||
"declarations" : [ {
|
||||
"kind" : "VarDef",
|
||||
"location" : [ 2, 5, 2, 13 ],
|
||||
"var" : {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 2, 5, 2, 9 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 2, 5, 2, 5 ],
|
||||
"name" : "x"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 2, 7, 2, 9 ],
|
||||
"className" : "int"
|
||||
}
|
||||
},
|
||||
"value" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 2, 13, 2, 13 ],
|
||||
"value" : 1
|
||||
}
|
||||
} ]
|
||||
} ],
|
||||
"statements" : [ {
|
||||
"kind" : "AssignStmt",
|
||||
"location" : [ 4, 1, 4, 9 ],
|
||||
"targets" : [ {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 4, 1, 4, 1 ],
|
||||
"name" : "f"
|
||||
} ],
|
||||
"value" : {
|
||||
"kind" : "CallExpr",
|
||||
"location" : [ 4, 5, 4, 9 ],
|
||||
"function" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 4, 5, 4, 7 ],
|
||||
"name" : "Foo"
|
||||
},
|
||||
"args" : [ ]
|
||||
}
|
||||
}, {
|
||||
"kind" : "AssignStmt",
|
||||
"location" : [ 5, 1, 5, 7 ],
|
||||
"targets" : [ {
|
||||
"kind" : "MemberExpr",
|
||||
"location" : [ 5, 1, 5, 3 ],
|
||||
"object" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 5, 1, 5, 1 ],
|
||||
"name" : "f"
|
||||
},
|
||||
"member" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 5, 3, 5, 3 ],
|
||||
"name" : "x"
|
||||
}
|
||||
} ],
|
||||
"value" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 5, 7, 5, 7 ],
|
||||
"value" : 2
|
||||
}
|
||||
} ],
|
||||
"errors" : {
|
||||
"errors" : [ ],
|
||||
"kind" : "Errors",
|
||||
"location" : [ 0, 0, 0, 0 ]
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
class Foo(object):
|
||||
x:int = 0
|
||||
|
||||
def __init__(self:"Foo", x:int):
|
||||
self.x = x
|
||||
|
||||
f = Foo(1)
|
||||
print(f.x)
|
@ -0,0 +1,159 @@
|
||||
{
|
||||
"kind" : "Program",
|
||||
"location" : [ 1, 1, 8, 11 ],
|
||||
"declarations" : [ {
|
||||
"kind" : "ClassDef",
|
||||
"location" : [ 1, 1, 7, 0 ],
|
||||
"name" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 1, 7, 1, 9 ],
|
||||
"name" : "Foo"
|
||||
},
|
||||
"superClass" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 1, 11, 1, 16 ],
|
||||
"name" : "object"
|
||||
},
|
||||
"declarations" : [ {
|
||||
"kind" : "VarDef",
|
||||
"location" : [ 2, 5, 2, 13 ],
|
||||
"var" : {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 2, 5, 2, 9 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 2, 5, 2, 5 ],
|
||||
"name" : "x"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 2, 7, 2, 9 ],
|
||||
"className" : "int"
|
||||
}
|
||||
},
|
||||
"value" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 2, 13, 2, 13 ],
|
||||
"value" : 0
|
||||
}
|
||||
}, {
|
||||
"kind" : "FuncDef",
|
||||
"location" : [ 4, 5, 5, 19 ],
|
||||
"name" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 4, 9, 4, 16 ],
|
||||
"name" : "__init__"
|
||||
},
|
||||
"params" : [ {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 4, 18, 4, 27 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 4, 18, 4, 21 ],
|
||||
"name" : "self"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 4, 23, 4, 27 ],
|
||||
"className" : "Foo"
|
||||
}
|
||||
}, {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 4, 30, 4, 34 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 4, 30, 4, 30 ],
|
||||
"name" : "x"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 4, 32, 4, 34 ],
|
||||
"className" : "int"
|
||||
}
|
||||
} ],
|
||||
"returnType" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 4, 36, 4, 36 ],
|
||||
"className" : "<None>"
|
||||
},
|
||||
"declarations" : [ ],
|
||||
"statements" : [ {
|
||||
"kind" : "AssignStmt",
|
||||
"location" : [ 5, 9, 5, 18 ],
|
||||
"targets" : [ {
|
||||
"kind" : "MemberExpr",
|
||||
"location" : [ 5, 9, 5, 14 ],
|
||||
"object" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 5, 9, 5, 12 ],
|
||||
"name" : "self"
|
||||
},
|
||||
"member" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 5, 14, 5, 14 ],
|
||||
"name" : "x"
|
||||
}
|
||||
} ],
|
||||
"value" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 5, 18, 5, 18 ],
|
||||
"name" : "x"
|
||||
}
|
||||
} ]
|
||||
} ]
|
||||
} ],
|
||||
"statements" : [ {
|
||||
"kind" : "AssignStmt",
|
||||
"location" : [ 7, 1, 7, 10 ],
|
||||
"targets" : [ {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 7, 1, 7, 1 ],
|
||||
"name" : "f"
|
||||
} ],
|
||||
"value" : {
|
||||
"kind" : "CallExpr",
|
||||
"location" : [ 7, 5, 7, 10 ],
|
||||
"function" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 7, 5, 7, 7 ],
|
||||
"name" : "Foo"
|
||||
},
|
||||
"args" : [ {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 7, 9, 7, 9 ],
|
||||
"value" : 1
|
||||
} ]
|
||||
}
|
||||
}, {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 8, 1, 8, 10 ],
|
||||
"expr" : {
|
||||
"kind" : "CallExpr",
|
||||
"location" : [ 8, 1, 8, 10 ],
|
||||
"function" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 8, 1, 8, 5 ],
|
||||
"name" : "print"
|
||||
},
|
||||
"args" : [ {
|
||||
"kind" : "MemberExpr",
|
||||
"location" : [ 8, 7, 8, 9 ],
|
||||
"object" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 8, 7, 8, 7 ],
|
||||
"name" : "f"
|
||||
},
|
||||
"member" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 8, 9, 8, 9 ],
|
||||
"name" : "x"
|
||||
}
|
||||
} ]
|
||||
}
|
||||
} ],
|
||||
"errors" : {
|
||||
"errors" : [ ],
|
||||
"kind" : "Errors",
|
||||
"location" : [ 0, 0, 0, 0 ]
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
class Foo(object):
|
||||
x:int = 0
|
||||
|
||||
def set(self:"Foo", x:int) -> object:
|
||||
self.x = x
|
||||
|
||||
f = Foo()
|
||||
f.set(1)
|
||||
print(f.x)
|
@ -0,0 +1,181 @@
|
||||
{
|
||||
"kind" : "Program",
|
||||
"location" : [ 1, 1, 9, 11 ],
|
||||
"declarations" : [ {
|
||||
"kind" : "ClassDef",
|
||||
"location" : [ 1, 1, 7, 0 ],
|
||||
"name" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 1, 7, 1, 9 ],
|
||||
"name" : "Foo"
|
||||
},
|
||||
"superClass" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 1, 11, 1, 16 ],
|
||||
"name" : "object"
|
||||
},
|
||||
"declarations" : [ {
|
||||
"kind" : "VarDef",
|
||||
"location" : [ 2, 5, 2, 13 ],
|
||||
"var" : {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 2, 5, 2, 9 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 2, 5, 2, 5 ],
|
||||
"name" : "x"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 2, 7, 2, 9 ],
|
||||
"className" : "int"
|
||||
}
|
||||
},
|
||||
"value" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 2, 13, 2, 13 ],
|
||||
"value" : 0
|
||||
}
|
||||
}, {
|
||||
"kind" : "FuncDef",
|
||||
"location" : [ 4, 5, 5, 19 ],
|
||||
"name" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 4, 9, 4, 11 ],
|
||||
"name" : "set"
|
||||
},
|
||||
"params" : [ {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 4, 13, 4, 22 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 4, 13, 4, 16 ],
|
||||
"name" : "self"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 4, 18, 4, 22 ],
|
||||
"className" : "Foo"
|
||||
}
|
||||
}, {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 4, 25, 4, 29 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 4, 25, 4, 25 ],
|
||||
"name" : "x"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 4, 27, 4, 29 ],
|
||||
"className" : "int"
|
||||
}
|
||||
} ],
|
||||
"returnType" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 4, 35, 4, 40 ],
|
||||
"className" : "object"
|
||||
},
|
||||
"declarations" : [ ],
|
||||
"statements" : [ {
|
||||
"kind" : "AssignStmt",
|
||||
"location" : [ 5, 9, 5, 18 ],
|
||||
"targets" : [ {
|
||||
"kind" : "MemberExpr",
|
||||
"location" : [ 5, 9, 5, 14 ],
|
||||
"object" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 5, 9, 5, 12 ],
|
||||
"name" : "self"
|
||||
},
|
||||
"member" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 5, 14, 5, 14 ],
|
||||
"name" : "x"
|
||||
}
|
||||
} ],
|
||||
"value" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 5, 18, 5, 18 ],
|
||||
"name" : "x"
|
||||
}
|
||||
} ]
|
||||
} ]
|
||||
} ],
|
||||
"statements" : [ {
|
||||
"kind" : "AssignStmt",
|
||||
"location" : [ 7, 1, 7, 9 ],
|
||||
"targets" : [ {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 7, 1, 7, 1 ],
|
||||
"name" : "f"
|
||||
} ],
|
||||
"value" : {
|
||||
"kind" : "CallExpr",
|
||||
"location" : [ 7, 5, 7, 9 ],
|
||||
"function" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 7, 5, 7, 7 ],
|
||||
"name" : "Foo"
|
||||
},
|
||||
"args" : [ ]
|
||||
}
|
||||
}, {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 8, 1, 8, 8 ],
|
||||
"expr" : {
|
||||
"kind" : "MethodCallExpr",
|
||||
"location" : [ 8, 1, 8, 8 ],
|
||||
"method" : {
|
||||
"kind" : "MemberExpr",
|
||||
"location" : [ 8, 1, 8, 5 ],
|
||||
"object" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 8, 1, 8, 1 ],
|
||||
"name" : "f"
|
||||
},
|
||||
"member" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 8, 3, 8, 5 ],
|
||||
"name" : "set"
|
||||
}
|
||||
},
|
||||
"args" : [ {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 8, 7, 8, 7 ],
|
||||
"value" : 1
|
||||
} ]
|
||||
}
|
||||
}, {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 9, 1, 9, 10 ],
|
||||
"expr" : {
|
||||
"kind" : "CallExpr",
|
||||
"location" : [ 9, 1, 9, 10 ],
|
||||
"function" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 9, 1, 9, 5 ],
|
||||
"name" : "print"
|
||||
},
|
||||
"args" : [ {
|
||||
"kind" : "MemberExpr",
|
||||
"location" : [ 9, 7, 9, 9 ],
|
||||
"object" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 9, 7, 9, 7 ],
|
||||
"name" : "f"
|
||||
},
|
||||
"member" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 9, 9, 9, 9 ],
|
||||
"name" : "x"
|
||||
}
|
||||
} ]
|
||||
}
|
||||
} ],
|
||||
"errors" : {
|
||||
"errors" : [ ],
|
||||
"kind" : "Errors",
|
||||
"location" : [ 0, 0, 0, 0 ]
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
count:int = 0
|
||||
|
||||
def foo(s: str) -> int:
|
||||
return len(s)
|
||||
|
||||
class bar(object):
|
||||
p: bool = True
|
||||
|
||||
def baz(self:"bar", xx: [int]) -> str:
|
||||
global count
|
||||
x:int = 0
|
||||
y:int = 1
|
||||
|
||||
def qux(y: int) -> object:
|
||||
nonlocal x
|
||||
if x > y:
|
||||
x = -1
|
||||
|
||||
for x in xx:
|
||||
self.p = x == 2
|
||||
|
||||
qux(0) # Yay! ChocoPy
|
||||
|
||||
count = count + 1
|
||||
|
||||
while x <= 0:
|
||||
if self.p:
|
||||
xx[0] = xx[1]
|
||||
self.p = not self.p
|
||||
x = x + 1
|
||||
elif foo("Long"[0]) == 1:
|
||||
return self is None
|
||||
|
||||
return "Nope"
|
||||
|
||||
print(bar().baz([1,2]))
|
||||
|
||||
|
@ -0,0 +1,613 @@
|
||||
{
|
||||
"kind" : "Program",
|
||||
"location" : [ 1, 1, 36, 24 ],
|
||||
"declarations" : [ {
|
||||
"kind" : "VarDef",
|
||||
"location" : [ 1, 1, 1, 13 ],
|
||||
"var" : {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 1, 1, 1, 9 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 1, 1, 1, 5 ],
|
||||
"name" : "count"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 1, 7, 1, 9 ],
|
||||
"className" : "int"
|
||||
}
|
||||
},
|
||||
"value" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 1, 13, 1, 13 ],
|
||||
"value" : 0
|
||||
}
|
||||
}, {
|
||||
"kind" : "FuncDef",
|
||||
"location" : [ 3, 1, 4, 18 ],
|
||||
"name" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 3, 5, 3, 7 ],
|
||||
"name" : "foo"
|
||||
},
|
||||
"params" : [ {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 3, 9, 3, 14 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 3, 9, 3, 9 ],
|
||||
"name" : "s"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 3, 12, 3, 14 ],
|
||||
"className" : "str"
|
||||
}
|
||||
} ],
|
||||
"returnType" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 3, 20, 3, 22 ],
|
||||
"className" : "int"
|
||||
},
|
||||
"declarations" : [ ],
|
||||
"statements" : [ {
|
||||
"kind" : "ReturnStmt",
|
||||
"location" : [ 4, 5, 4, 17 ],
|
||||
"value" : {
|
||||
"kind" : "CallExpr",
|
||||
"location" : [ 4, 12, 4, 17 ],
|
||||
"function" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 4, 12, 4, 14 ],
|
||||
"name" : "len"
|
||||
},
|
||||
"args" : [ {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 4, 16, 4, 16 ],
|
||||
"name" : "s"
|
||||
} ]
|
||||
}
|
||||
} ]
|
||||
}, {
|
||||
"kind" : "ClassDef",
|
||||
"location" : [ 6, 1, 36, 0 ],
|
||||
"name" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 6, 7, 6, 9 ],
|
||||
"name" : "bar"
|
||||
},
|
||||
"superClass" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 6, 11, 6, 16 ],
|
||||
"name" : "object"
|
||||
},
|
||||
"declarations" : [ {
|
||||
"kind" : "VarDef",
|
||||
"location" : [ 7, 5, 7, 18 ],
|
||||
"var" : {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 7, 5, 7, 11 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 7, 5, 7, 5 ],
|
||||
"name" : "p"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 7, 8, 7, 11 ],
|
||||
"className" : "bool"
|
||||
}
|
||||
},
|
||||
"value" : {
|
||||
"kind" : "BooleanLiteral",
|
||||
"location" : [ 7, 15, 7, 18 ],
|
||||
"value" : true
|
||||
}
|
||||
}, {
|
||||
"kind" : "FuncDef",
|
||||
"location" : [ 9, 5, 34, 22 ],
|
||||
"name" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 9, 9, 9, 11 ],
|
||||
"name" : "baz"
|
||||
},
|
||||
"params" : [ {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 9, 13, 9, 22 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 9, 13, 9, 16 ],
|
||||
"name" : "self"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 9, 18, 9, 22 ],
|
||||
"className" : "bar"
|
||||
}
|
||||
}, {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 9, 25, 9, 33 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 9, 25, 9, 26 ],
|
||||
"name" : "xx"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ListType",
|
||||
"location" : [ 9, 29, 9, 33 ],
|
||||
"elementType" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 9, 30, 9, 32 ],
|
||||
"className" : "int"
|
||||
}
|
||||
}
|
||||
} ],
|
||||
"returnType" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 9, 39, 9, 41 ],
|
||||
"className" : "str"
|
||||
},
|
||||
"declarations" : [ {
|
||||
"kind" : "GlobalDecl",
|
||||
"location" : [ 10, 9, 10, 20 ],
|
||||
"variable" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 10, 16, 10, 20 ],
|
||||
"name" : "count"
|
||||
}
|
||||
}, {
|
||||
"kind" : "VarDef",
|
||||
"location" : [ 11, 9, 11, 17 ],
|
||||
"var" : {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 11, 9, 11, 13 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 11, 9, 11, 9 ],
|
||||
"name" : "x"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 11, 11, 11, 13 ],
|
||||
"className" : "int"
|
||||
}
|
||||
},
|
||||
"value" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 11, 17, 11, 17 ],
|
||||
"value" : 0
|
||||
}
|
||||
}, {
|
||||
"kind" : "VarDef",
|
||||
"location" : [ 12, 9, 12, 17 ],
|
||||
"var" : {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 12, 9, 12, 13 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 12, 9, 12, 9 ],
|
||||
"name" : "y"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 12, 11, 12, 13 ],
|
||||
"className" : "int"
|
||||
}
|
||||
},
|
||||
"value" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 12, 17, 12, 17 ],
|
||||
"value" : 1
|
||||
}
|
||||
}, {
|
||||
"kind" : "FuncDef",
|
||||
"location" : [ 14, 9, 19, 8 ],
|
||||
"name" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 14, 13, 14, 15 ],
|
||||
"name" : "qux"
|
||||
},
|
||||
"params" : [ {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 14, 17, 14, 22 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 14, 17, 14, 17 ],
|
||||
"name" : "y"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 14, 20, 14, 22 ],
|
||||
"className" : "int"
|
||||
}
|
||||
} ],
|
||||
"returnType" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 14, 28, 14, 33 ],
|
||||
"className" : "object"
|
||||
},
|
||||
"declarations" : [ {
|
||||
"kind" : "NonLocalDecl",
|
||||
"location" : [ 15, 13, 15, 22 ],
|
||||
"variable" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 15, 22, 15, 22 ],
|
||||
"name" : "x"
|
||||
}
|
||||
} ],
|
||||
"statements" : [ {
|
||||
"kind" : "IfStmt",
|
||||
"location" : [ 16, 13, 19, 8 ],
|
||||
"condition" : {
|
||||
"kind" : "BinaryExpr",
|
||||
"location" : [ 16, 16, 16, 20 ],
|
||||
"left" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 16, 16, 16, 16 ],
|
||||
"name" : "x"
|
||||
},
|
||||
"operator" : ">",
|
||||
"right" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 16, 20, 16, 20 ],
|
||||
"name" : "y"
|
||||
}
|
||||
},
|
||||
"thenBody" : [ {
|
||||
"kind" : "AssignStmt",
|
||||
"location" : [ 17, 17, 17, 22 ],
|
||||
"targets" : [ {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 17, 17, 17, 17 ],
|
||||
"name" : "x"
|
||||
} ],
|
||||
"value" : {
|
||||
"kind" : "UnaryExpr",
|
||||
"location" : [ 17, 21, 17, 22 ],
|
||||
"operator" : "-",
|
||||
"operand" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 17, 22, 17, 22 ],
|
||||
"value" : 1
|
||||
}
|
||||
}
|
||||
} ],
|
||||
"elseBody" : [ ]
|
||||
} ]
|
||||
} ],
|
||||
"statements" : [ {
|
||||
"kind" : "ForStmt",
|
||||
"location" : [ 19, 9, 22, 8 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 19, 13, 19, 13 ],
|
||||
"name" : "x"
|
||||
},
|
||||
"iterable" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 19, 18, 19, 19 ],
|
||||
"name" : "xx"
|
||||
},
|
||||
"body" : [ {
|
||||
"kind" : "AssignStmt",
|
||||
"location" : [ 20, 13, 20, 27 ],
|
||||
"targets" : [ {
|
||||
"kind" : "MemberExpr",
|
||||
"location" : [ 20, 13, 20, 18 ],
|
||||
"object" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 20, 13, 20, 16 ],
|
||||
"name" : "self"
|
||||
},
|
||||
"member" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 20, 18, 20, 18 ],
|
||||
"name" : "p"
|
||||
}
|
||||
} ],
|
||||
"value" : {
|
||||
"kind" : "BinaryExpr",
|
||||
"location" : [ 20, 22, 20, 27 ],
|
||||
"left" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 20, 22, 20, 22 ],
|
||||
"name" : "x"
|
||||
},
|
||||
"operator" : "==",
|
||||
"right" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 20, 27, 20, 27 ],
|
||||
"value" : 2
|
||||
}
|
||||
}
|
||||
} ]
|
||||
}, {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 22, 9, 22, 14 ],
|
||||
"expr" : {
|
||||
"kind" : "CallExpr",
|
||||
"location" : [ 22, 9, 22, 14 ],
|
||||
"function" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 22, 9, 22, 11 ],
|
||||
"name" : "qux"
|
||||
},
|
||||
"args" : [ {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 22, 13, 22, 13 ],
|
||||
"value" : 0
|
||||
} ]
|
||||
}
|
||||
}, {
|
||||
"kind" : "AssignStmt",
|
||||
"location" : [ 24, 9, 24, 25 ],
|
||||
"targets" : [ {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 24, 9, 24, 13 ],
|
||||
"name" : "count"
|
||||
} ],
|
||||
"value" : {
|
||||
"kind" : "BinaryExpr",
|
||||
"location" : [ 24, 17, 24, 25 ],
|
||||
"left" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 24, 17, 24, 21 ],
|
||||
"name" : "count"
|
||||
},
|
||||
"operator" : "+",
|
||||
"right" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 24, 25, 24, 25 ],
|
||||
"value" : 1
|
||||
}
|
||||
}
|
||||
}, {
|
||||
"kind" : "WhileStmt",
|
||||
"location" : [ 26, 9, 34, 8 ],
|
||||
"condition" : {
|
||||
"kind" : "BinaryExpr",
|
||||
"location" : [ 26, 15, 26, 20 ],
|
||||
"left" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 26, 15, 26, 15 ],
|
||||
"name" : "x"
|
||||
},
|
||||
"operator" : "<=",
|
||||
"right" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 26, 20, 26, 20 ],
|
||||
"value" : 0
|
||||
}
|
||||
},
|
||||
"body" : [ {
|
||||
"kind" : "IfStmt",
|
||||
"location" : [ 27, 13, 34, 8 ],
|
||||
"condition" : {
|
||||
"kind" : "MemberExpr",
|
||||
"location" : [ 27, 16, 27, 21 ],
|
||||
"object" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 27, 16, 27, 19 ],
|
||||
"name" : "self"
|
||||
},
|
||||
"member" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 27, 21, 27, 21 ],
|
||||
"name" : "p"
|
||||
}
|
||||
},
|
||||
"thenBody" : [ {
|
||||
"kind" : "AssignStmt",
|
||||
"location" : [ 28, 17, 28, 29 ],
|
||||
"targets" : [ {
|
||||
"kind" : "IndexExpr",
|
||||
"location" : [ 28, 17, 28, 21 ],
|
||||
"list" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 28, 17, 28, 18 ],
|
||||
"name" : "xx"
|
||||
},
|
||||
"index" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 28, 20, 28, 20 ],
|
||||
"value" : 0
|
||||
}
|
||||
} ],
|
||||
"value" : {
|
||||
"kind" : "IndexExpr",
|
||||
"location" : [ 28, 25, 28, 29 ],
|
||||
"list" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 28, 25, 28, 26 ],
|
||||
"name" : "xx"
|
||||
},
|
||||
"index" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 28, 28, 28, 28 ],
|
||||
"value" : 1
|
||||
}
|
||||
}
|
||||
}, {
|
||||
"kind" : "AssignStmt",
|
||||
"location" : [ 29, 17, 29, 35 ],
|
||||
"targets" : [ {
|
||||
"kind" : "MemberExpr",
|
||||
"location" : [ 29, 17, 29, 22 ],
|
||||
"object" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 29, 17, 29, 20 ],
|
||||
"name" : "self"
|
||||
},
|
||||
"member" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 29, 22, 29, 22 ],
|
||||
"name" : "p"
|
||||
}
|
||||
} ],
|
||||
"value" : {
|
||||
"kind" : "UnaryExpr",
|
||||
"location" : [ 29, 26, 29, 35 ],
|
||||
"operator" : "not",
|
||||
"operand" : {
|
||||
"kind" : "MemberExpr",
|
||||
"location" : [ 29, 30, 29, 35 ],
|
||||
"object" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 29, 30, 29, 33 ],
|
||||
"name" : "self"
|
||||
},
|
||||
"member" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 29, 35, 29, 35 ],
|
||||
"name" : "p"
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
"kind" : "AssignStmt",
|
||||
"location" : [ 30, 17, 30, 25 ],
|
||||
"targets" : [ {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 30, 17, 30, 17 ],
|
||||
"name" : "x"
|
||||
} ],
|
||||
"value" : {
|
||||
"kind" : "BinaryExpr",
|
||||
"location" : [ 30, 21, 30, 25 ],
|
||||
"left" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 30, 21, 30, 21 ],
|
||||
"name" : "x"
|
||||
},
|
||||
"operator" : "+",
|
||||
"right" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 30, 25, 30, 25 ],
|
||||
"value" : 1
|
||||
}
|
||||
}
|
||||
} ],
|
||||
"elseBody" : [ {
|
||||
"kind" : "IfStmt",
|
||||
"location" : [ 31, 13, 34, 8 ],
|
||||
"condition" : {
|
||||
"kind" : "BinaryExpr",
|
||||
"location" : [ 31, 18, 31, 36 ],
|
||||
"left" : {
|
||||
"kind" : "CallExpr",
|
||||
"location" : [ 31, 18, 31, 31 ],
|
||||
"function" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 31, 18, 31, 20 ],
|
||||
"name" : "foo"
|
||||
},
|
||||
"args" : [ {
|
||||
"kind" : "IndexExpr",
|
||||
"location" : [ 31, 22, 31, 30 ],
|
||||
"list" : {
|
||||
"kind" : "StringLiteral",
|
||||
"location" : [ 31, 22, 31, 27 ],
|
||||
"value" : "Long"
|
||||
},
|
||||
"index" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 31, 29, 31, 29 ],
|
||||
"value" : 0
|
||||
}
|
||||
} ]
|
||||
},
|
||||
"operator" : "==",
|
||||
"right" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 31, 36, 31, 36 ],
|
||||
"value" : 1
|
||||
}
|
||||
},
|
||||
"thenBody" : [ {
|
||||
"kind" : "ReturnStmt",
|
||||
"location" : [ 32, 17, 32, 35 ],
|
||||
"value" : {
|
||||
"kind" : "BinaryExpr",
|
||||
"location" : [ 32, 24, 32, 35 ],
|
||||
"left" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 32, 24, 32, 27 ],
|
||||
"name" : "self"
|
||||
},
|
||||
"operator" : "is",
|
||||
"right" : {
|
||||
"kind" : "NoneLiteral",
|
||||
"location" : [ 32, 32, 32, 35 ]
|
||||
}
|
||||
}
|
||||
} ],
|
||||
"elseBody" : [ ]
|
||||
} ]
|
||||
} ]
|
||||
}, {
|
||||
"kind" : "ReturnStmt",
|
||||
"location" : [ 34, 9, 34, 21 ],
|
||||
"value" : {
|
||||
"kind" : "StringLiteral",
|
||||
"location" : [ 34, 16, 34, 21 ],
|
||||
"value" : "Nope"
|
||||
}
|
||||
} ]
|
||||
} ]
|
||||
} ],
|
||||
"statements" : [ {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 36, 1, 36, 23 ],
|
||||
"expr" : {
|
||||
"kind" : "CallExpr",
|
||||
"location" : [ 36, 1, 36, 23 ],
|
||||
"function" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 36, 1, 36, 5 ],
|
||||
"name" : "print"
|
||||
},
|
||||
"args" : [ {
|
||||
"kind" : "MethodCallExpr",
|
||||
"location" : [ 36, 7, 36, 22 ],
|
||||
"method" : {
|
||||
"kind" : "MemberExpr",
|
||||
"location" : [ 36, 7, 36, 15 ],
|
||||
"object" : {
|
||||
"kind" : "CallExpr",
|
||||
"location" : [ 36, 7, 36, 11 ],
|
||||
"function" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 36, 7, 36, 9 ],
|
||||
"name" : "bar"
|
||||
},
|
||||
"args" : [ ]
|
||||
},
|
||||
"member" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 36, 13, 36, 15 ],
|
||||
"name" : "baz"
|
||||
}
|
||||
},
|
||||
"args" : [ {
|
||||
"kind" : "ListExpr",
|
||||
"location" : [ 36, 17, 36, 21 ],
|
||||
"elements" : [ {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 36, 18, 36, 18 ],
|
||||
"value" : 1
|
||||
}, {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 36, 20, 36, 20 ],
|
||||
"value" : 2
|
||||
} ]
|
||||
} ]
|
||||
} ]
|
||||
}
|
||||
} ],
|
||||
"errors" : {
|
||||
"errors" : [ ],
|
||||
"kind" : "Errors",
|
||||
"location" : [ 0, 0, 0, 0 ]
|
||||
}
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
def foo() -> int:
|
||||
return 1
|
||||
|
||||
foo()
|
@ -0,0 +1,48 @@
|
||||
{
|
||||
"kind" : "Program",
|
||||
"location" : [ 1, 1, 4, 6 ],
|
||||
"declarations" : [ {
|
||||
"kind" : "FuncDef",
|
||||
"location" : [ 1, 1, 2, 13 ],
|
||||
"name" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 1, 5, 1, 7 ],
|
||||
"name" : "foo"
|
||||
},
|
||||
"params" : [ ],
|
||||
"returnType" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 1, 14, 1, 16 ],
|
||||
"className" : "int"
|
||||
},
|
||||
"declarations" : [ ],
|
||||
"statements" : [ {
|
||||
"kind" : "ReturnStmt",
|
||||
"location" : [ 2, 5, 2, 12 ],
|
||||
"value" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 2, 12, 2, 12 ],
|
||||
"value" : 1
|
||||
}
|
||||
} ]
|
||||
} ],
|
||||
"statements" : [ {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 4, 1, 4, 5 ],
|
||||
"expr" : {
|
||||
"kind" : "CallExpr",
|
||||
"location" : [ 4, 1, 4, 5 ],
|
||||
"function" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 4, 1, 4, 3 ],
|
||||
"name" : "foo"
|
||||
},
|
||||
"args" : [ ]
|
||||
}
|
||||
} ],
|
||||
"errors" : {
|
||||
"errors" : [ ],
|
||||
"kind" : "Errors",
|
||||
"location" : [ 0, 0, 0, 0 ]
|
||||
}
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
def foo(x:int, y:int) -> bool:
|
||||
return x > y
|
||||
|
||||
foo(1,2)
|
@ -0,0 +1,92 @@
|
||||
{
|
||||
"kind" : "Program",
|
||||
"location" : [ 1, 1, 4, 9 ],
|
||||
"declarations" : [ {
|
||||
"kind" : "FuncDef",
|
||||
"location" : [ 1, 1, 2, 17 ],
|
||||
"name" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 1, 5, 1, 7 ],
|
||||
"name" : "foo"
|
||||
},
|
||||
"params" : [ {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 1, 9, 1, 13 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 1, 9, 1, 9 ],
|
||||
"name" : "x"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 1, 11, 1, 13 ],
|
||||
"className" : "int"
|
||||
}
|
||||
}, {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 1, 16, 1, 20 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 1, 16, 1, 16 ],
|
||||
"name" : "y"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 1, 18, 1, 20 ],
|
||||
"className" : "int"
|
||||
}
|
||||
} ],
|
||||
"returnType" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 1, 26, 1, 29 ],
|
||||
"className" : "bool"
|
||||
},
|
||||
"declarations" : [ ],
|
||||
"statements" : [ {
|
||||
"kind" : "ReturnStmt",
|
||||
"location" : [ 2, 5, 2, 16 ],
|
||||
"value" : {
|
||||
"kind" : "BinaryExpr",
|
||||
"location" : [ 2, 12, 2, 16 ],
|
||||
"left" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 2, 12, 2, 12 ],
|
||||
"name" : "x"
|
||||
},
|
||||
"operator" : ">",
|
||||
"right" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 2, 16, 2, 16 ],
|
||||
"name" : "y"
|
||||
}
|
||||
}
|
||||
} ]
|
||||
} ],
|
||||
"statements" : [ {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 4, 1, 4, 8 ],
|
||||
"expr" : {
|
||||
"kind" : "CallExpr",
|
||||
"location" : [ 4, 1, 4, 8 ],
|
||||
"function" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 4, 1, 4, 3 ],
|
||||
"name" : "foo"
|
||||
},
|
||||
"args" : [ {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 4, 5, 4, 5 ],
|
||||
"value" : 1
|
||||
}, {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 4, 7, 4, 7 ],
|
||||
"value" : 2
|
||||
} ]
|
||||
}
|
||||
} ],
|
||||
"errors" : {
|
||||
"errors" : [ ],
|
||||
"kind" : "Errors",
|
||||
"location" : [ 0, 0, 0, 0 ]
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
z:int = 0
|
||||
|
||||
def foo(x:int) -> bool:
|
||||
global z
|
||||
return x > z
|
||||
|
||||
foo(1)
|
@ -0,0 +1,105 @@
|
||||
{
|
||||
"kind" : "Program",
|
||||
"location" : [ 1, 1, 7, 7 ],
|
||||
"declarations" : [ {
|
||||
"kind" : "VarDef",
|
||||
"location" : [ 1, 1, 1, 9 ],
|
||||
"var" : {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 1, 1, 1, 5 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 1, 1, 1, 1 ],
|
||||
"name" : "z"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 1, 3, 1, 5 ],
|
||||
"className" : "int"
|
||||
}
|
||||
},
|
||||
"value" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 1, 9, 1, 9 ],
|
||||
"value" : 0
|
||||
}
|
||||
}, {
|
||||
"kind" : "FuncDef",
|
||||
"location" : [ 3, 1, 5, 17 ],
|
||||
"name" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 3, 5, 3, 7 ],
|
||||
"name" : "foo"
|
||||
},
|
||||
"params" : [ {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 3, 9, 3, 13 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 3, 9, 3, 9 ],
|
||||
"name" : "x"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 3, 11, 3, 13 ],
|
||||
"className" : "int"
|
||||
}
|
||||
} ],
|
||||
"returnType" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 3, 19, 3, 22 ],
|
||||
"className" : "bool"
|
||||
},
|
||||
"declarations" : [ {
|
||||
"kind" : "GlobalDecl",
|
||||
"location" : [ 4, 5, 4, 12 ],
|
||||
"variable" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 4, 12, 4, 12 ],
|
||||
"name" : "z"
|
||||
}
|
||||
} ],
|
||||
"statements" : [ {
|
||||
"kind" : "ReturnStmt",
|
||||
"location" : [ 5, 5, 5, 16 ],
|
||||
"value" : {
|
||||
"kind" : "BinaryExpr",
|
||||
"location" : [ 5, 12, 5, 16 ],
|
||||
"left" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 5, 12, 5, 12 ],
|
||||
"name" : "x"
|
||||
},
|
||||
"operator" : ">",
|
||||
"right" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 5, 16, 5, 16 ],
|
||||
"name" : "z"
|
||||
}
|
||||
}
|
||||
} ]
|
||||
} ],
|
||||
"statements" : [ {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 7, 1, 7, 6 ],
|
||||
"expr" : {
|
||||
"kind" : "CallExpr",
|
||||
"location" : [ 7, 1, 7, 6 ],
|
||||
"function" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 7, 1, 7, 3 ],
|
||||
"name" : "foo"
|
||||
},
|
||||
"args" : [ {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 7, 5, 7, 5 ],
|
||||
"value" : 1
|
||||
} ]
|
||||
}
|
||||
} ],
|
||||
"errors" : {
|
||||
"errors" : [ ],
|
||||
"kind" : "Errors",
|
||||
"location" : [ 0, 0, 0, 0 ]
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
|
||||
def foo(x:int) -> bool:
|
||||
a:int = 0
|
||||
b:int = 1
|
||||
def bar(y: int) -> int:
|
||||
a:int = 2
|
||||
return y
|
||||
return bar(x) > a
|
||||
|
||||
foo(1)
|
@ -0,0 +1,187 @@
|
||||
{
|
||||
"kind" : "Program",
|
||||
"location" : [ 2, 1, 10, 7 ],
|
||||
"declarations" : [ {
|
||||
"kind" : "FuncDef",
|
||||
"location" : [ 2, 1, 8, 22 ],
|
||||
"name" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 2, 5, 2, 7 ],
|
||||
"name" : "foo"
|
||||
},
|
||||
"params" : [ {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 2, 9, 2, 13 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 2, 9, 2, 9 ],
|
||||
"name" : "x"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 2, 11, 2, 13 ],
|
||||
"className" : "int"
|
||||
}
|
||||
} ],
|
||||
"returnType" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 2, 19, 2, 22 ],
|
||||
"className" : "bool"
|
||||
},
|
||||
"declarations" : [ {
|
||||
"kind" : "VarDef",
|
||||
"location" : [ 3, 5, 3, 13 ],
|
||||
"var" : {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 3, 5, 3, 9 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 3, 5, 3, 5 ],
|
||||
"name" : "a"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 3, 7, 3, 9 ],
|
||||
"className" : "int"
|
||||
}
|
||||
},
|
||||
"value" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 3, 13, 3, 13 ],
|
||||
"value" : 0
|
||||
}
|
||||
}, {
|
||||
"kind" : "VarDef",
|
||||
"location" : [ 4, 5, 4, 13 ],
|
||||
"var" : {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 4, 5, 4, 9 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 4, 5, 4, 5 ],
|
||||
"name" : "b"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 4, 7, 4, 9 ],
|
||||
"className" : "int"
|
||||
}
|
||||
},
|
||||
"value" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 4, 13, 4, 13 ],
|
||||
"value" : 1
|
||||
}
|
||||
}, {
|
||||
"kind" : "FuncDef",
|
||||
"location" : [ 5, 5, 7, 17 ],
|
||||
"name" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 5, 9, 5, 11 ],
|
||||
"name" : "bar"
|
||||
},
|
||||
"params" : [ {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 5, 13, 5, 18 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 5, 13, 5, 13 ],
|
||||
"name" : "y"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 5, 16, 5, 18 ],
|
||||
"className" : "int"
|
||||
}
|
||||
} ],
|
||||
"returnType" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 5, 24, 5, 26 ],
|
||||
"className" : "int"
|
||||
},
|
||||
"declarations" : [ {
|
||||
"kind" : "VarDef",
|
||||
"location" : [ 6, 9, 6, 17 ],
|
||||
"var" : {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 6, 9, 6, 13 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 6, 9, 6, 9 ],
|
||||
"name" : "a"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 6, 11, 6, 13 ],
|
||||
"className" : "int"
|
||||
}
|
||||
},
|
||||
"value" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 6, 17, 6, 17 ],
|
||||
"value" : 2
|
||||
}
|
||||
} ],
|
||||
"statements" : [ {
|
||||
"kind" : "ReturnStmt",
|
||||
"location" : [ 7, 9, 7, 16 ],
|
||||
"value" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 7, 16, 7, 16 ],
|
||||
"name" : "y"
|
||||
}
|
||||
} ]
|
||||
} ],
|
||||
"statements" : [ {
|
||||
"kind" : "ReturnStmt",
|
||||
"location" : [ 8, 5, 8, 21 ],
|
||||
"value" : {
|
||||
"kind" : "BinaryExpr",
|
||||
"location" : [ 8, 12, 8, 21 ],
|
||||
"left" : {
|
||||
"kind" : "CallExpr",
|
||||
"location" : [ 8, 12, 8, 17 ],
|
||||
"function" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 8, 12, 8, 14 ],
|
||||
"name" : "bar"
|
||||
},
|
||||
"args" : [ {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 8, 16, 8, 16 ],
|
||||
"name" : "x"
|
||||
} ]
|
||||
},
|
||||
"operator" : ">",
|
||||
"right" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 8, 21, 8, 21 ],
|
||||
"name" : "a"
|
||||
}
|
||||
}
|
||||
} ]
|
||||
} ],
|
||||
"statements" : [ {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 10, 1, 10, 6 ],
|
||||
"expr" : {
|
||||
"kind" : "CallExpr",
|
||||
"location" : [ 10, 1, 10, 6 ],
|
||||
"function" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 10, 1, 10, 3 ],
|
||||
"name" : "foo"
|
||||
},
|
||||
"args" : [ {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 10, 5, 10, 5 ],
|
||||
"value" : 1
|
||||
} ]
|
||||
}
|
||||
} ],
|
||||
"errors" : {
|
||||
"errors" : [ ],
|
||||
"kind" : "Errors",
|
||||
"location" : [ 0, 0, 0, 0 ]
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
|
||||
def foo(x:int) -> bool:
|
||||
a:int = 0
|
||||
b:int = 1
|
||||
def bar(y: int) -> int:
|
||||
nonlocal a
|
||||
a = 2
|
||||
return y
|
||||
return bar(x) > a
|
||||
|
||||
foo(1)
|
@ -0,0 +1,186 @@
|
||||
{
|
||||
"kind" : "Program",
|
||||
"location" : [ 2, 1, 11, 7 ],
|
||||
"declarations" : [ {
|
||||
"kind" : "FuncDef",
|
||||
"location" : [ 2, 1, 9, 22 ],
|
||||
"name" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 2, 5, 2, 7 ],
|
||||
"name" : "foo"
|
||||
},
|
||||
"params" : [ {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 2, 9, 2, 13 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 2, 9, 2, 9 ],
|
||||
"name" : "x"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 2, 11, 2, 13 ],
|
||||
"className" : "int"
|
||||
}
|
||||
} ],
|
||||
"returnType" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 2, 19, 2, 22 ],
|
||||
"className" : "bool"
|
||||
},
|
||||
"declarations" : [ {
|
||||
"kind" : "VarDef",
|
||||
"location" : [ 3, 5, 3, 13 ],
|
||||
"var" : {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 3, 5, 3, 9 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 3, 5, 3, 5 ],
|
||||
"name" : "a"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 3, 7, 3, 9 ],
|
||||
"className" : "int"
|
||||
}
|
||||
},
|
||||
"value" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 3, 13, 3, 13 ],
|
||||
"value" : 0
|
||||
}
|
||||
}, {
|
||||
"kind" : "VarDef",
|
||||
"location" : [ 4, 5, 4, 13 ],
|
||||
"var" : {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 4, 5, 4, 9 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 4, 5, 4, 5 ],
|
||||
"name" : "b"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 4, 7, 4, 9 ],
|
||||
"className" : "int"
|
||||
}
|
||||
},
|
||||
"value" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 4, 13, 4, 13 ],
|
||||
"value" : 1
|
||||
}
|
||||
}, {
|
||||
"kind" : "FuncDef",
|
||||
"location" : [ 5, 5, 8, 17 ],
|
||||
"name" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 5, 9, 5, 11 ],
|
||||
"name" : "bar"
|
||||
},
|
||||
"params" : [ {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 5, 13, 5, 18 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 5, 13, 5, 13 ],
|
||||
"name" : "y"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 5, 16, 5, 18 ],
|
||||
"className" : "int"
|
||||
}
|
||||
} ],
|
||||
"returnType" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 5, 24, 5, 26 ],
|
||||
"className" : "int"
|
||||
},
|
||||
"declarations" : [ {
|
||||
"kind" : "NonLocalDecl",
|
||||
"location" : [ 6, 9, 6, 18 ],
|
||||
"variable" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 6, 18, 6, 18 ],
|
||||
"name" : "a"
|
||||
}
|
||||
} ],
|
||||
"statements" : [ {
|
||||
"kind" : "AssignStmt",
|
||||
"location" : [ 7, 9, 7, 13 ],
|
||||
"targets" : [ {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 7, 9, 7, 9 ],
|
||||
"name" : "a"
|
||||
} ],
|
||||
"value" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 7, 13, 7, 13 ],
|
||||
"value" : 2
|
||||
}
|
||||
}, {
|
||||
"kind" : "ReturnStmt",
|
||||
"location" : [ 8, 9, 8, 16 ],
|
||||
"value" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 8, 16, 8, 16 ],
|
||||
"name" : "y"
|
||||
}
|
||||
} ]
|
||||
} ],
|
||||
"statements" : [ {
|
||||
"kind" : "ReturnStmt",
|
||||
"location" : [ 9, 5, 9, 21 ],
|
||||
"value" : {
|
||||
"kind" : "BinaryExpr",
|
||||
"location" : [ 9, 12, 9, 21 ],
|
||||
"left" : {
|
||||
"kind" : "CallExpr",
|
||||
"location" : [ 9, 12, 9, 17 ],
|
||||
"function" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 9, 12, 9, 14 ],
|
||||
"name" : "bar"
|
||||
},
|
||||
"args" : [ {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 9, 16, 9, 16 ],
|
||||
"name" : "x"
|
||||
} ]
|
||||
},
|
||||
"operator" : ">",
|
||||
"right" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 9, 21, 9, 21 ],
|
||||
"name" : "a"
|
||||
}
|
||||
}
|
||||
} ]
|
||||
} ],
|
||||
"statements" : [ {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 11, 1, 11, 6 ],
|
||||
"expr" : {
|
||||
"kind" : "CallExpr",
|
||||
"location" : [ 11, 1, 11, 6 ],
|
||||
"function" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 11, 1, 11, 3 ],
|
||||
"name" : "foo"
|
||||
},
|
||||
"args" : [ {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 11, 5, 11, 5 ],
|
||||
"value" : 1
|
||||
} ]
|
||||
}
|
||||
} ],
|
||||
"errors" : {
|
||||
"errors" : [ ],
|
||||
"kind" : "Errors",
|
||||
"location" : [ 0, 0, 0, 0 ]
|
||||
}
|
||||
}
|
@ -0,0 +1 @@
|
||||
3 if 1 > 2 else 4
|
@ -0,0 +1,43 @@
|
||||
{
|
||||
"kind" : "Program",
|
||||
"location" : [ 1, 1, 1, 18 ],
|
||||
"declarations" : [ ],
|
||||
"statements" : [ {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 1, 1, 1, 17 ],
|
||||
"expr" : {
|
||||
"kind" : "IfExpr",
|
||||
"location" : [ 1, 1, 1, 17 ],
|
||||
"condition" : {
|
||||
"kind" : "BinaryExpr",
|
||||
"location" : [ 1, 6, 1, 10 ],
|
||||
"left" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 1, 6, 1, 6 ],
|
||||
"value" : 1
|
||||
},
|
||||
"operator" : ">",
|
||||
"right" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 1, 10, 1, 10 ],
|
||||
"value" : 2
|
||||
}
|
||||
},
|
||||
"thenExpr" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 1, 1, 1, 1 ],
|
||||
"value" : 3
|
||||
},
|
||||
"elseExpr" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 1, 17, 1, 17 ],
|
||||
"value" : 4
|
||||
}
|
||||
}
|
||||
} ],
|
||||
"errors" : {
|
||||
"errors" : [ ],
|
||||
"kind" : "Errors",
|
||||
"location" : [ 0, 0, 0, 0 ]
|
||||
}
|
||||
}
|
@ -0,0 +1 @@
|
||||
3 if 1 > 2 else 4 if 1 < 0 else 5
|
@ -0,0 +1,67 @@
|
||||
{
|
||||
"kind" : "Program",
|
||||
"location" : [ 1, 1, 1, 34 ],
|
||||
"declarations" : [ ],
|
||||
"statements" : [ {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 1, 1, 1, 33 ],
|
||||
"expr" : {
|
||||
"kind" : "IfExpr",
|
||||
"location" : [ 1, 1, 1, 33 ],
|
||||
"condition" : {
|
||||
"kind" : "BinaryExpr",
|
||||
"location" : [ 1, 6, 1, 10 ],
|
||||
"left" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 1, 6, 1, 6 ],
|
||||
"value" : 1
|
||||
},
|
||||
"operator" : ">",
|
||||
"right" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 1, 10, 1, 10 ],
|
||||
"value" : 2
|
||||
}
|
||||
},
|
||||
"thenExpr" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 1, 1, 1, 1 ],
|
||||
"value" : 3
|
||||
},
|
||||
"elseExpr" : {
|
||||
"kind" : "IfExpr",
|
||||
"location" : [ 1, 17, 1, 33 ],
|
||||
"condition" : {
|
||||
"kind" : "BinaryExpr",
|
||||
"location" : [ 1, 22, 1, 26 ],
|
||||
"left" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 1, 22, 1, 22 ],
|
||||
"value" : 1
|
||||
},
|
||||
"operator" : "<",
|
||||
"right" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 1, 26, 1, 26 ],
|
||||
"value" : 0
|
||||
}
|
||||
},
|
||||
"thenExpr" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 1, 17, 1, 17 ],
|
||||
"value" : 4
|
||||
},
|
||||
"elseExpr" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 1, 33, 1, 33 ],
|
||||
"value" : 5
|
||||
}
|
||||
}
|
||||
}
|
||||
} ],
|
||||
"errors" : {
|
||||
"errors" : [ ],
|
||||
"kind" : "Errors",
|
||||
"location" : [ 0, 0, 0, 0 ]
|
||||
}
|
||||
}
|
@ -0,0 +1 @@
|
||||
a + b[i][j]
|
@ -0,0 +1,47 @@
|
||||
{
|
||||
"kind" : "Program",
|
||||
"location" : [ 1, 1, 1, 12 ],
|
||||
"declarations" : [ ],
|
||||
"statements" : [ {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 1, 1, 1, 11 ],
|
||||
"expr" : {
|
||||
"kind" : "BinaryExpr",
|
||||
"location" : [ 1, 1, 1, 11 ],
|
||||
"left" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 1, 1, 1, 1 ],
|
||||
"name" : "a"
|
||||
},
|
||||
"operator" : "+",
|
||||
"right" : {
|
||||
"kind" : "IndexExpr",
|
||||
"location" : [ 1, 5, 1, 11 ],
|
||||
"list" : {
|
||||
"kind" : "IndexExpr",
|
||||
"location" : [ 1, 5, 1, 8 ],
|
||||
"list" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 1, 5, 1, 5 ],
|
||||
"name" : "b"
|
||||
},
|
||||
"index" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 1, 7, 1, 7 ],
|
||||
"name" : "i"
|
||||
}
|
||||
},
|
||||
"index" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 1, 10, 1, 10 ],
|
||||
"name" : "j"
|
||||
}
|
||||
}
|
||||
}
|
||||
} ],
|
||||
"errors" : {
|
||||
"errors" : [ ],
|
||||
"kind" : "Errors",
|
||||
"location" : [ 0, 0, 0, 0 ]
|
||||
}
|
||||
}
|
@ -0,0 +1 @@
|
||||
1 + 2 + 3
|
@ -0,0 +1,39 @@
|
||||
{
|
||||
"kind" : "Program",
|
||||
"location" : [ 1, 1, 1, 10 ],
|
||||
"declarations" : [ ],
|
||||
"statements" : [ {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 1, 1, 1, 9 ],
|
||||
"expr" : {
|
||||
"kind" : "BinaryExpr",
|
||||
"location" : [ 1, 1, 1, 9 ],
|
||||
"left" : {
|
||||
"kind" : "BinaryExpr",
|
||||
"location" : [ 1, 1, 1, 5 ],
|
||||
"left" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 1, 1, 1, 1 ],
|
||||
"value" : 1
|
||||
},
|
||||
"operator" : "+",
|
||||
"right" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 1, 5, 1, 5 ],
|
||||
"value" : 2
|
||||
}
|
||||
},
|
||||
"operator" : "+",
|
||||
"right" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 1, 9, 1, 9 ],
|
||||
"value" : 3
|
||||
}
|
||||
}
|
||||
} ],
|
||||
"errors" : {
|
||||
"errors" : [ ],
|
||||
"kind" : "Errors",
|
||||
"location" : [ 0, 0, 0, 0 ]
|
||||
}
|
||||
}
|
@ -0,0 +1 @@
|
||||
-1
|
@ -0,0 +1,24 @@
|
||||
{
|
||||
"kind" : "Program",
|
||||
"location" : [ 1, 1, 1, 3 ],
|
||||
"declarations" : [ ],
|
||||
"statements" : [ {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 1, 1, 1, 2 ],
|
||||
"expr" : {
|
||||
"kind" : "UnaryExpr",
|
||||
"location" : [ 1, 1, 1, 2 ],
|
||||
"operator" : "-",
|
||||
"operand" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 1, 2, 1, 2 ],
|
||||
"value" : 1
|
||||
}
|
||||
}
|
||||
} ],
|
||||
"errors" : {
|
||||
"errors" : [ ],
|
||||
"kind" : "Errors",
|
||||
"location" : [ 0, 0, 0, 0 ]
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
x:int = 1
|
||||
|
||||
x = 2
|
||||
|
||||
print(x)
|
@ -0,0 +1,63 @@
|
||||
{
|
||||
"kind" : "Program",
|
||||
"location" : [ 1, 1, 5, 9 ],
|
||||
"declarations" : [ {
|
||||
"kind" : "VarDef",
|
||||
"location" : [ 1, 1, 1, 9 ],
|
||||
"var" : {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 1, 1, 1, 5 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 1, 1, 1, 1 ],
|
||||
"name" : "x"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 1, 3, 1, 5 ],
|
||||
"className" : "int"
|
||||
}
|
||||
},
|
||||
"value" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 1, 9, 1, 9 ],
|
||||
"value" : 1
|
||||
}
|
||||
} ],
|
||||
"statements" : [ {
|
||||
"kind" : "AssignStmt",
|
||||
"location" : [ 3, 1, 3, 5 ],
|
||||
"targets" : [ {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 3, 1, 3, 1 ],
|
||||
"name" : "x"
|
||||
} ],
|
||||
"value" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 3, 5, 3, 5 ],
|
||||
"value" : 2
|
||||
}
|
||||
}, {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 5, 1, 5, 8 ],
|
||||
"expr" : {
|
||||
"kind" : "CallExpr",
|
||||
"location" : [ 5, 1, 5, 8 ],
|
||||
"function" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 5, 1, 5, 5 ],
|
||||
"name" : "print"
|
||||
},
|
||||
"args" : [ {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 5, 7, 5, 7 ],
|
||||
"name" : "x"
|
||||
} ]
|
||||
}
|
||||
} ],
|
||||
"errors" : {
|
||||
"errors" : [ ],
|
||||
"kind" : "Errors",
|
||||
"location" : [ 0, 0, 0, 0 ]
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
True
|
||||
False
|
||||
1
|
||||
None
|
||||
"This is a string"
|
||||
[1, 2, 3]
|
||||
|
@ -0,0 +1,70 @@
|
||||
{
|
||||
"kind" : "Program",
|
||||
"location" : [ 1, 1, 6, 10 ],
|
||||
"declarations" : [ ],
|
||||
"statements" : [ {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 1, 1, 1, 4 ],
|
||||
"expr" : {
|
||||
"kind" : "BooleanLiteral",
|
||||
"location" : [ 1, 1, 1, 4 ],
|
||||
"value" : true
|
||||
}
|
||||
}, {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 2, 1, 2, 5 ],
|
||||
"expr" : {
|
||||
"kind" : "BooleanLiteral",
|
||||
"location" : [ 2, 1, 2, 5 ],
|
||||
"value" : false
|
||||
}
|
||||
}, {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 3, 1, 3, 1 ],
|
||||
"expr" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 3, 1, 3, 1 ],
|
||||
"value" : 1
|
||||
}
|
||||
}, {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 4, 1, 4, 4 ],
|
||||
"expr" : {
|
||||
"kind" : "NoneLiteral",
|
||||
"location" : [ 4, 1, 4, 4 ]
|
||||
}
|
||||
}, {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 5, 1, 5, 18 ],
|
||||
"expr" : {
|
||||
"kind" : "StringLiteral",
|
||||
"location" : [ 5, 1, 5, 18 ],
|
||||
"value" : "This is a string"
|
||||
}
|
||||
}, {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 6, 1, 6, 9 ],
|
||||
"expr" : {
|
||||
"kind" : "ListExpr",
|
||||
"location" : [ 6, 1, 6, 9 ],
|
||||
"elements" : [ {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 6, 2, 6, 2 ],
|
||||
"value" : 1
|
||||
}, {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 6, 5, 6, 5 ],
|
||||
"value" : 2
|
||||
}, {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 6, 8, 6, 8 ],
|
||||
"value" : 3
|
||||
} ]
|
||||
}
|
||||
} ],
|
||||
"errors" : {
|
||||
"errors" : [ ],
|
||||
"kind" : "Errors",
|
||||
"location" : [ 0, 0, 0, 0 ]
|
||||
}
|
||||
}
|
@ -0,0 +1 @@
|
||||
print(1)
|
@ -0,0 +1,28 @@
|
||||
{
|
||||
"kind" : "Program",
|
||||
"location" : [ 1, 1, 1, 9 ],
|
||||
"declarations" : [ ],
|
||||
"statements" : [ {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 1, 1, 1, 8 ],
|
||||
"expr" : {
|
||||
"kind" : "CallExpr",
|
||||
"location" : [ 1, 1, 1, 8 ],
|
||||
"function" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 1, 1, 1, 5 ],
|
||||
"name" : "print"
|
||||
},
|
||||
"args" : [ {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 1, 7, 1, 7 ],
|
||||
"value" : 1
|
||||
} ]
|
||||
}
|
||||
} ],
|
||||
"errors" : {
|
||||
"errors" : [ ],
|
||||
"kind" : "Errors",
|
||||
"location" : [ 0, 0, 0, 0 ]
|
||||
}
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
x:int = 0
|
||||
for x in [1, 2, 3]:
|
||||
print(x)
|
||||
|
@ -0,0 +1,76 @@
|
||||
{
|
||||
"kind" : "Program",
|
||||
"location" : [ 1, 1, 5, 1 ],
|
||||
"declarations" : [ {
|
||||
"kind" : "VarDef",
|
||||
"location" : [ 1, 1, 1, 9 ],
|
||||
"var" : {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 1, 1, 1, 5 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 1, 1, 1, 1 ],
|
||||
"name" : "x"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 1, 3, 1, 5 ],
|
||||
"className" : "int"
|
||||
}
|
||||
},
|
||||
"value" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 1, 9, 1, 9 ],
|
||||
"value" : 0
|
||||
}
|
||||
} ],
|
||||
"statements" : [ {
|
||||
"kind" : "ForStmt",
|
||||
"location" : [ 2, 1, 5, 1 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 2, 5, 2, 5 ],
|
||||
"name" : "x"
|
||||
},
|
||||
"iterable" : {
|
||||
"kind" : "ListExpr",
|
||||
"location" : [ 2, 10, 2, 18 ],
|
||||
"elements" : [ {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 2, 11, 2, 11 ],
|
||||
"value" : 1
|
||||
}, {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 2, 14, 2, 14 ],
|
||||
"value" : 2
|
||||
}, {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 2, 17, 2, 17 ],
|
||||
"value" : 3
|
||||
} ]
|
||||
},
|
||||
"body" : [ {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 3, 5, 3, 12 ],
|
||||
"expr" : {
|
||||
"kind" : "CallExpr",
|
||||
"location" : [ 3, 5, 3, 12 ],
|
||||
"function" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 3, 5, 3, 9 ],
|
||||
"name" : "print"
|
||||
},
|
||||
"args" : [ {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 3, 11, 3, 11 ],
|
||||
"name" : "x"
|
||||
} ]
|
||||
}
|
||||
} ]
|
||||
} ],
|
||||
"errors" : {
|
||||
"errors" : [ ],
|
||||
"kind" : "Errors",
|
||||
"location" : [ 0, 0, 0, 0 ]
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
if True:
|
||||
False
|
||||
|
@ -0,0 +1,29 @@
|
||||
{
|
||||
"kind" : "Program",
|
||||
"location" : [ 1, 1, 4, 1 ],
|
||||
"declarations" : [ ],
|
||||
"statements" : [ {
|
||||
"kind" : "IfStmt",
|
||||
"location" : [ 1, 1, 4, 1 ],
|
||||
"condition" : {
|
||||
"kind" : "BooleanLiteral",
|
||||
"location" : [ 1, 4, 1, 7 ],
|
||||
"value" : true
|
||||
},
|
||||
"thenBody" : [ {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 2, 5, 2, 9 ],
|
||||
"expr" : {
|
||||
"kind" : "BooleanLiteral",
|
||||
"location" : [ 2, 5, 2, 9 ],
|
||||
"value" : false
|
||||
}
|
||||
} ],
|
||||
"elseBody" : [ ]
|
||||
} ],
|
||||
"errors" : {
|
||||
"errors" : [ ],
|
||||
"kind" : "Errors",
|
||||
"location" : [ 0, 0, 0, 0 ]
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
if 1 > 2:
|
||||
print(1)
|
||||
elif 3 == 4:
|
||||
print(2)
|
||||
elif True:
|
||||
print(3)
|
@ -0,0 +1,112 @@
|
||||
{
|
||||
"kind" : "Program",
|
||||
"location" : [ 1, 1, 7, 1 ],
|
||||
"declarations" : [ ],
|
||||
"statements" : [ {
|
||||
"kind" : "IfStmt",
|
||||
"location" : [ 1, 1, 7, 1 ],
|
||||
"condition" : {
|
||||
"kind" : "BinaryExpr",
|
||||
"location" : [ 1, 4, 1, 8 ],
|
||||
"left" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 1, 4, 1, 4 ],
|
||||
"value" : 1
|
||||
},
|
||||
"operator" : ">",
|
||||
"right" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 1, 8, 1, 8 ],
|
||||
"value" : 2
|
||||
}
|
||||
},
|
||||
"thenBody" : [ {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 2, 5, 2, 12 ],
|
||||
"expr" : {
|
||||
"kind" : "CallExpr",
|
||||
"location" : [ 2, 5, 2, 12 ],
|
||||
"function" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 2, 5, 2, 9 ],
|
||||
"name" : "print"
|
||||
},
|
||||
"args" : [ {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 2, 11, 2, 11 ],
|
||||
"value" : 1
|
||||
} ]
|
||||
}
|
||||
} ],
|
||||
"elseBody" : [ {
|
||||
"kind" : "IfStmt",
|
||||
"location" : [ 3, 1, 7, 1 ],
|
||||
"condition" : {
|
||||
"kind" : "BinaryExpr",
|
||||
"location" : [ 3, 6, 3, 11 ],
|
||||
"left" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 3, 6, 3, 6 ],
|
||||
"value" : 3
|
||||
},
|
||||
"operator" : "==",
|
||||
"right" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 3, 11, 3, 11 ],
|
||||
"value" : 4
|
||||
}
|
||||
},
|
||||
"thenBody" : [ {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 4, 5, 4, 12 ],
|
||||
"expr" : {
|
||||
"kind" : "CallExpr",
|
||||
"location" : [ 4, 5, 4, 12 ],
|
||||
"function" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 4, 5, 4, 9 ],
|
||||
"name" : "print"
|
||||
},
|
||||
"args" : [ {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 4, 11, 4, 11 ],
|
||||
"value" : 2
|
||||
} ]
|
||||
}
|
||||
} ],
|
||||
"elseBody" : [ {
|
||||
"kind" : "IfStmt",
|
||||
"location" : [ 5, 1, 7, 1 ],
|
||||
"condition" : {
|
||||
"kind" : "BooleanLiteral",
|
||||
"location" : [ 5, 6, 5, 9 ],
|
||||
"value" : true
|
||||
},
|
||||
"thenBody" : [ {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 6, 5, 6, 12 ],
|
||||
"expr" : {
|
||||
"kind" : "CallExpr",
|
||||
"location" : [ 6, 5, 6, 12 ],
|
||||
"function" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 6, 5, 6, 9 ],
|
||||
"name" : "print"
|
||||
},
|
||||
"args" : [ {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 6, 11, 6, 11 ],
|
||||
"value" : 3
|
||||
} ]
|
||||
}
|
||||
} ],
|
||||
"elseBody" : [ ]
|
||||
} ]
|
||||
} ]
|
||||
} ],
|
||||
"errors" : {
|
||||
"errors" : [ ],
|
||||
"kind" : "Errors",
|
||||
"location" : [ 0, 0, 0, 0 ]
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
if 1 > 2:
|
||||
print(1)
|
||||
elif 3 == 4:
|
||||
print(2)
|
||||
elif True:
|
||||
print(3)
|
||||
else:
|
||||
print(4)
|
@ -0,0 +1,129 @@
|
||||
{
|
||||
"kind" : "Program",
|
||||
"location" : [ 1, 1, 9, 1 ],
|
||||
"declarations" : [ ],
|
||||
"statements" : [ {
|
||||
"kind" : "IfStmt",
|
||||
"location" : [ 1, 1, 9, 1 ],
|
||||
"condition" : {
|
||||
"kind" : "BinaryExpr",
|
||||
"location" : [ 1, 4, 1, 8 ],
|
||||
"left" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 1, 4, 1, 4 ],
|
||||
"value" : 1
|
||||
},
|
||||
"operator" : ">",
|
||||
"right" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 1, 8, 1, 8 ],
|
||||
"value" : 2
|
||||
}
|
||||
},
|
||||
"thenBody" : [ {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 2, 5, 2, 12 ],
|
||||
"expr" : {
|
||||
"kind" : "CallExpr",
|
||||
"location" : [ 2, 5, 2, 12 ],
|
||||
"function" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 2, 5, 2, 9 ],
|
||||
"name" : "print"
|
||||
},
|
||||
"args" : [ {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 2, 11, 2, 11 ],
|
||||
"value" : 1
|
||||
} ]
|
||||
}
|
||||
} ],
|
||||
"elseBody" : [ {
|
||||
"kind" : "IfStmt",
|
||||
"location" : [ 3, 1, 9, 1 ],
|
||||
"condition" : {
|
||||
"kind" : "BinaryExpr",
|
||||
"location" : [ 3, 6, 3, 11 ],
|
||||
"left" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 3, 6, 3, 6 ],
|
||||
"value" : 3
|
||||
},
|
||||
"operator" : "==",
|
||||
"right" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 3, 11, 3, 11 ],
|
||||
"value" : 4
|
||||
}
|
||||
},
|
||||
"thenBody" : [ {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 4, 5, 4, 12 ],
|
||||
"expr" : {
|
||||
"kind" : "CallExpr",
|
||||
"location" : [ 4, 5, 4, 12 ],
|
||||
"function" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 4, 5, 4, 9 ],
|
||||
"name" : "print"
|
||||
},
|
||||
"args" : [ {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 4, 11, 4, 11 ],
|
||||
"value" : 2
|
||||
} ]
|
||||
}
|
||||
} ],
|
||||
"elseBody" : [ {
|
||||
"kind" : "IfStmt",
|
||||
"location" : [ 5, 1, 9, 1 ],
|
||||
"condition" : {
|
||||
"kind" : "BooleanLiteral",
|
||||
"location" : [ 5, 6, 5, 9 ],
|
||||
"value" : true
|
||||
},
|
||||
"thenBody" : [ {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 6, 5, 6, 12 ],
|
||||
"expr" : {
|
||||
"kind" : "CallExpr",
|
||||
"location" : [ 6, 5, 6, 12 ],
|
||||
"function" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 6, 5, 6, 9 ],
|
||||
"name" : "print"
|
||||
},
|
||||
"args" : [ {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 6, 11, 6, 11 ],
|
||||
"value" : 3
|
||||
} ]
|
||||
}
|
||||
} ],
|
||||
"elseBody" : [ {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 8, 5, 8, 12 ],
|
||||
"expr" : {
|
||||
"kind" : "CallExpr",
|
||||
"location" : [ 8, 5, 8, 12 ],
|
||||
"function" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 8, 5, 8, 9 ],
|
||||
"name" : "print"
|
||||
},
|
||||
"args" : [ {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 8, 11, 8, 11 ],
|
||||
"value" : 4
|
||||
} ]
|
||||
}
|
||||
} ]
|
||||
} ]
|
||||
} ]
|
||||
} ],
|
||||
"errors" : {
|
||||
"errors" : [ ],
|
||||
"kind" : "Errors",
|
||||
"location" : [ 0, 0, 0, 0 ]
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
if True:
|
||||
False
|
||||
else:
|
||||
True
|
||||
|
@ -0,0 +1,37 @@
|
||||
{
|
||||
"kind" : "Program",
|
||||
"location" : [ 1, 1, 6, 1 ],
|
||||
"declarations" : [ ],
|
||||
"statements" : [ {
|
||||
"kind" : "IfStmt",
|
||||
"location" : [ 1, 1, 6, 1 ],
|
||||
"condition" : {
|
||||
"kind" : "BooleanLiteral",
|
||||
"location" : [ 1, 4, 1, 7 ],
|
||||
"value" : true
|
||||
},
|
||||
"thenBody" : [ {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 2, 5, 2, 9 ],
|
||||
"expr" : {
|
||||
"kind" : "BooleanLiteral",
|
||||
"location" : [ 2, 5, 2, 9 ],
|
||||
"value" : false
|
||||
}
|
||||
} ],
|
||||
"elseBody" : [ {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 4, 5, 4, 8 ],
|
||||
"expr" : {
|
||||
"kind" : "BooleanLiteral",
|
||||
"location" : [ 4, 5, 4, 8 ],
|
||||
"value" : true
|
||||
}
|
||||
} ]
|
||||
} ],
|
||||
"errors" : {
|
||||
"errors" : [ ],
|
||||
"kind" : "Errors",
|
||||
"location" : [ 0, 0, 0, 0 ]
|
||||
}
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
x:int = None
|
||||
|
||||
x = [1, 2, 3]
|
||||
x[0] = x[1]
|
@ -0,0 +1,88 @@
|
||||
{
|
||||
"kind" : "Program",
|
||||
"location" : [ 1, 1, 4, 12 ],
|
||||
"declarations" : [ {
|
||||
"kind" : "VarDef",
|
||||
"location" : [ 1, 1, 1, 12 ],
|
||||
"var" : {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 1, 1, 1, 5 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 1, 1, 1, 1 ],
|
||||
"name" : "x"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 1, 3, 1, 5 ],
|
||||
"className" : "int"
|
||||
}
|
||||
},
|
||||
"value" : {
|
||||
"kind" : "NoneLiteral",
|
||||
"location" : [ 1, 9, 1, 12 ]
|
||||
}
|
||||
} ],
|
||||
"statements" : [ {
|
||||
"kind" : "AssignStmt",
|
||||
"location" : [ 3, 1, 3, 13 ],
|
||||
"targets" : [ {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 3, 1, 3, 1 ],
|
||||
"name" : "x"
|
||||
} ],
|
||||
"value" : {
|
||||
"kind" : "ListExpr",
|
||||
"location" : [ 3, 5, 3, 13 ],
|
||||
"elements" : [ {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 3, 6, 3, 6 ],
|
||||
"value" : 1
|
||||
}, {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 3, 9, 3, 9 ],
|
||||
"value" : 2
|
||||
}, {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 3, 12, 3, 12 ],
|
||||
"value" : 3
|
||||
} ]
|
||||
}
|
||||
}, {
|
||||
"kind" : "AssignStmt",
|
||||
"location" : [ 4, 1, 4, 11 ],
|
||||
"targets" : [ {
|
||||
"kind" : "IndexExpr",
|
||||
"location" : [ 4, 1, 4, 4 ],
|
||||
"list" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 4, 1, 4, 1 ],
|
||||
"name" : "x"
|
||||
},
|
||||
"index" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 4, 3, 4, 3 ],
|
||||
"value" : 0
|
||||
}
|
||||
} ],
|
||||
"value" : {
|
||||
"kind" : "IndexExpr",
|
||||
"location" : [ 4, 8, 4, 11 ],
|
||||
"list" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 4, 8, 4, 8 ],
|
||||
"name" : "x"
|
||||
},
|
||||
"index" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 4, 10, 4, 10 ],
|
||||
"value" : 1
|
||||
}
|
||||
}
|
||||
} ],
|
||||
"errors" : {
|
||||
"errors" : [ ],
|
||||
"kind" : "Errors",
|
||||
"location" : [ 0, 0, 0, 0 ]
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
while True:
|
||||
pass
|
||||
|
@ -0,0 +1,20 @@
|
||||
{
|
||||
"kind" : "Program",
|
||||
"location" : [ 1, 1, 4, 1 ],
|
||||
"declarations" : [ ],
|
||||
"statements" : [ {
|
||||
"kind" : "WhileStmt",
|
||||
"location" : [ 1, 1, 4, 1 ],
|
||||
"condition" : {
|
||||
"kind" : "BooleanLiteral",
|
||||
"location" : [ 1, 7, 1, 10 ],
|
||||
"value" : true
|
||||
},
|
||||
"body" : [ ]
|
||||
} ],
|
||||
"errors" : {
|
||||
"errors" : [ ],
|
||||
"kind" : "Errors",
|
||||
"location" : [ 0, 0, 0, 0 ]
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
class weight(object):
|
||||
value: int = 0
|
||||
|
||||
def __init__(self: "weight", value: int):
|
||||
self.value = value
|
||||
|
||||
def __repr__(self: "weight"):
|
||||
return "weight(" + str(self.value) + ")"
|
||||
|
||||
|
||||
class graph(object):
|
||||
matrix: [[weight]] = None
|
||||
|
||||
def __init__(self: "graph", num_vertices: int):
|
||||
i: int = 0
|
||||
j: int = 0
|
||||
row: [weight] = None
|
||||
|
||||
self.matrix = []
|
||||
while i < num_vertices:
|
||||
j = 0
|
||||
row = []
|
||||
while j < num_vertices:
|
||||
row = row + [weight(0)]
|
||||
j = j + 1
|
||||
self.matrix = self.matrix + [row]
|
||||
i = i + 1
|
||||
|
||||
def add_edge(self: "graph", from_vertex: int, to_vertex: int, edge_weight: int):
|
||||
pass
|
||||
|
||||
def print(self: "graph"):
|
||||
for row in self.matrix:
|
||||
print(row)
|
||||
|
||||
|
||||
class undirectedgraph(graph):
|
||||
def add_edge(self: "undirectedgraph", from_vertex: int, to_vertex: int, edge_weight: int):
|
||||
self.matrix[from_vertex][to_vertex] = weight(edge_weight)
|
||||
self.matrix[to_vertex][from_vertex] = weight(edge_weight)
|
||||
|
||||
|
||||
class directedgraph(graph):
|
||||
def add_edge(self: "undirectedgraph", from_vertex: int, to_vertex: int, edge_weight: int):
|
||||
self.matrix[from_vertex][to_vertex] = weight(edge_weight)
|
||||
|
||||
|
||||
g = undirectedgraph(3)
|
||||
g.add_edge(0, 2, 100)
|
||||
g.print()
|
||||
|
||||
directedgraph(3).print()
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,62 @@
|
||||
def append(a: [int], k: int) -> [int]:
|
||||
return a + [k]
|
||||
|
||||
|
||||
def extend(a: [int], b: [int], b_start: int, b_end: int) -> [int]:
|
||||
extended: [int] = None
|
||||
i: int = 0
|
||||
|
||||
extended = a
|
||||
i = b_start
|
||||
while i < b_end:
|
||||
extended = append(extended, b[i])
|
||||
i = i + 1
|
||||
return extended
|
||||
|
||||
|
||||
def merge(left: [int], right: [int]) -> [int]:
|
||||
merged: [int] = None
|
||||
i: int = 0
|
||||
j: int = 0
|
||||
|
||||
merged = []
|
||||
while i < len(left) and j < len(right):
|
||||
if left[i] < right[j]:
|
||||
merged = append(merged, left[i])
|
||||
i = i + 1
|
||||
else:
|
||||
merged = append(merged, right[j])
|
||||
j = j + 1
|
||||
|
||||
if i < len(left):
|
||||
merged = extend(merged, left, i, len(left))
|
||||
if j < len(right):
|
||||
merged = extend(merged, right, j, len(right))
|
||||
|
||||
return merged
|
||||
|
||||
|
||||
def mergesort(a: [int]) -> [int]:
|
||||
mid: int = 0
|
||||
left: [int] = None
|
||||
right: [int] = None
|
||||
|
||||
if len(a) < 2:
|
||||
return a
|
||||
|
||||
mid = len(a) // 2
|
||||
left = extend([], a, 0, mid)
|
||||
right = extend([], a, mid, len(a))
|
||||
|
||||
left = mergesort(left)
|
||||
right = mergesort(right)
|
||||
return merge(left, right)
|
||||
|
||||
|
||||
initial: [int] = None
|
||||
ordered: [int] = None
|
||||
|
||||
initial = [2, 7, 3, 11, 5]
|
||||
ordered = mergesort(initial)
|
||||
|
||||
print(ordered)
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,45 @@
|
||||
class s(object):
|
||||
t: object = None
|
||||
|
||||
class r(object):
|
||||
sobj: s = None
|
||||
|
||||
class q(object):
|
||||
robj: r = None
|
||||
|
||||
class p(q):
|
||||
def f(self: "p") -> object:
|
||||
return self.robj.sobj.t
|
||||
|
||||
def a() -> int:
|
||||
def b() -> int:
|
||||
def c() -> int:
|
||||
def d() -> int:
|
||||
def e() -> int:
|
||||
return 1
|
||||
return e()
|
||||
return d()
|
||||
return c()
|
||||
return b()
|
||||
|
||||
def w():
|
||||
def x():
|
||||
def y():
|
||||
def z():
|
||||
4
|
||||
3
|
||||
2
|
||||
1
|
||||
|
||||
xs: [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[int]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]] = None
|
||||
xs = [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[1]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
|
||||
|
||||
if 1:
|
||||
if 2:
|
||||
if 3:
|
||||
if 4:
|
||||
True
|
||||
elif -3:
|
||||
False
|
||||
else:
|
||||
False
|
@ -0,0 +1,799 @@
|
||||
{
|
||||
"kind" : "Program",
|
||||
"location" : [ 1, 1, 46, 1 ],
|
||||
"declarations" : [ {
|
||||
"kind" : "ClassDef",
|
||||
"location" : [ 1, 1, 2, 21 ],
|
||||
"name" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 1, 7, 1, 7 ],
|
||||
"name" : "s"
|
||||
},
|
||||
"superClass" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 1, 9, 1, 14 ],
|
||||
"name" : "object"
|
||||
},
|
||||
"declarations" : [ {
|
||||
"kind" : "VarDef",
|
||||
"location" : [ 2, 5, 2, 20 ],
|
||||
"var" : {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 2, 5, 2, 13 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 2, 5, 2, 5 ],
|
||||
"name" : "t"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 2, 8, 2, 13 ],
|
||||
"className" : "object"
|
||||
}
|
||||
},
|
||||
"value" : {
|
||||
"kind" : "NoneLiteral",
|
||||
"location" : [ 2, 17, 2, 20 ]
|
||||
}
|
||||
} ]
|
||||
}, {
|
||||
"kind" : "ClassDef",
|
||||
"location" : [ 4, 1, 5, 19 ],
|
||||
"name" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 4, 7, 4, 7 ],
|
||||
"name" : "r"
|
||||
},
|
||||
"superClass" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 4, 9, 4, 14 ],
|
||||
"name" : "object"
|
||||
},
|
||||
"declarations" : [ {
|
||||
"kind" : "VarDef",
|
||||
"location" : [ 5, 5, 5, 18 ],
|
||||
"var" : {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 5, 5, 5, 11 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 5, 5, 5, 8 ],
|
||||
"name" : "sobj"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 5, 11, 5, 11 ],
|
||||
"className" : "s"
|
||||
}
|
||||
},
|
||||
"value" : {
|
||||
"kind" : "NoneLiteral",
|
||||
"location" : [ 5, 15, 5, 18 ]
|
||||
}
|
||||
} ]
|
||||
}, {
|
||||
"kind" : "ClassDef",
|
||||
"location" : [ 7, 1, 8, 19 ],
|
||||
"name" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 7, 7, 7, 7 ],
|
||||
"name" : "q"
|
||||
},
|
||||
"superClass" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 7, 9, 7, 14 ],
|
||||
"name" : "object"
|
||||
},
|
||||
"declarations" : [ {
|
||||
"kind" : "VarDef",
|
||||
"location" : [ 8, 5, 8, 18 ],
|
||||
"var" : {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 8, 5, 8, 11 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 8, 5, 8, 8 ],
|
||||
"name" : "robj"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 8, 11, 8, 11 ],
|
||||
"className" : "r"
|
||||
}
|
||||
},
|
||||
"value" : {
|
||||
"kind" : "NoneLiteral",
|
||||
"location" : [ 8, 15, 8, 18 ]
|
||||
}
|
||||
} ]
|
||||
}, {
|
||||
"kind" : "ClassDef",
|
||||
"location" : [ 10, 1, 14, 0 ],
|
||||
"name" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 10, 7, 10, 7 ],
|
||||
"name" : "p"
|
||||
},
|
||||
"superClass" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 10, 9, 10, 9 ],
|
||||
"name" : "q"
|
||||
},
|
||||
"declarations" : [ {
|
||||
"kind" : "FuncDef",
|
||||
"location" : [ 11, 5, 12, 32 ],
|
||||
"name" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 11, 9, 11, 9 ],
|
||||
"name" : "f"
|
||||
},
|
||||
"params" : [ {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 11, 11, 11, 19 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 11, 11, 11, 14 ],
|
||||
"name" : "self"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 11, 17, 11, 19 ],
|
||||
"className" : "p"
|
||||
}
|
||||
} ],
|
||||
"returnType" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 11, 25, 11, 30 ],
|
||||
"className" : "object"
|
||||
},
|
||||
"declarations" : [ ],
|
||||
"statements" : [ {
|
||||
"kind" : "ReturnStmt",
|
||||
"location" : [ 12, 9, 12, 31 ],
|
||||
"value" : {
|
||||
"kind" : "MemberExpr",
|
||||
"location" : [ 12, 16, 12, 31 ],
|
||||
"object" : {
|
||||
"kind" : "MemberExpr",
|
||||
"location" : [ 12, 16, 12, 29 ],
|
||||
"object" : {
|
||||
"kind" : "MemberExpr",
|
||||
"location" : [ 12, 16, 12, 24 ],
|
||||
"object" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 12, 16, 12, 19 ],
|
||||
"name" : "self"
|
||||
},
|
||||
"member" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 12, 21, 12, 24 ],
|
||||
"name" : "robj"
|
||||
}
|
||||
},
|
||||
"member" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 12, 26, 12, 29 ],
|
||||
"name" : "sobj"
|
||||
}
|
||||
},
|
||||
"member" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 12, 31, 12, 31 ],
|
||||
"name" : "t"
|
||||
}
|
||||
}
|
||||
} ]
|
||||
} ]
|
||||
}, {
|
||||
"kind" : "FuncDef",
|
||||
"location" : [ 14, 1, 23, 15 ],
|
||||
"name" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 14, 5, 14, 5 ],
|
||||
"name" : "a"
|
||||
},
|
||||
"params" : [ ],
|
||||
"returnType" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 14, 12, 14, 14 ],
|
||||
"className" : "int"
|
||||
},
|
||||
"declarations" : [ {
|
||||
"kind" : "FuncDef",
|
||||
"location" : [ 15, 5, 22, 19 ],
|
||||
"name" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 15, 9, 15, 9 ],
|
||||
"name" : "b"
|
||||
},
|
||||
"params" : [ ],
|
||||
"returnType" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 15, 16, 15, 18 ],
|
||||
"className" : "int"
|
||||
},
|
||||
"declarations" : [ {
|
||||
"kind" : "FuncDef",
|
||||
"location" : [ 16, 9, 21, 23 ],
|
||||
"name" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 16, 13, 16, 13 ],
|
||||
"name" : "c"
|
||||
},
|
||||
"params" : [ ],
|
||||
"returnType" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 16, 20, 16, 22 ],
|
||||
"className" : "int"
|
||||
},
|
||||
"declarations" : [ {
|
||||
"kind" : "FuncDef",
|
||||
"location" : [ 17, 13, 20, 27 ],
|
||||
"name" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 17, 17, 17, 17 ],
|
||||
"name" : "d"
|
||||
},
|
||||
"params" : [ ],
|
||||
"returnType" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 17, 24, 17, 26 ],
|
||||
"className" : "int"
|
||||
},
|
||||
"declarations" : [ {
|
||||
"kind" : "FuncDef",
|
||||
"location" : [ 18, 17, 19, 29 ],
|
||||
"name" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 18, 21, 18, 21 ],
|
||||
"name" : "e"
|
||||
},
|
||||
"params" : [ ],
|
||||
"returnType" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 18, 28, 18, 30 ],
|
||||
"className" : "int"
|
||||
},
|
||||
"declarations" : [ ],
|
||||
"statements" : [ {
|
||||
"kind" : "ReturnStmt",
|
||||
"location" : [ 19, 21, 19, 28 ],
|
||||
"value" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 19, 28, 19, 28 ],
|
||||
"value" : 1
|
||||
}
|
||||
} ]
|
||||
} ],
|
||||
"statements" : [ {
|
||||
"kind" : "ReturnStmt",
|
||||
"location" : [ 20, 17, 20, 26 ],
|
||||
"value" : {
|
||||
"kind" : "CallExpr",
|
||||
"location" : [ 20, 24, 20, 26 ],
|
||||
"function" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 20, 24, 20, 24 ],
|
||||
"name" : "e"
|
||||
},
|
||||
"args" : [ ]
|
||||
}
|
||||
} ]
|
||||
} ],
|
||||
"statements" : [ {
|
||||
"kind" : "ReturnStmt",
|
||||
"location" : [ 21, 13, 21, 22 ],
|
||||
"value" : {
|
||||
"kind" : "CallExpr",
|
||||
"location" : [ 21, 20, 21, 22 ],
|
||||
"function" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 21, 20, 21, 20 ],
|
||||
"name" : "d"
|
||||
},
|
||||
"args" : [ ]
|
||||
}
|
||||
} ]
|
||||
} ],
|
||||
"statements" : [ {
|
||||
"kind" : "ReturnStmt",
|
||||
"location" : [ 22, 9, 22, 18 ],
|
||||
"value" : {
|
||||
"kind" : "CallExpr",
|
||||
"location" : [ 22, 16, 22, 18 ],
|
||||
"function" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 22, 16, 22, 16 ],
|
||||
"name" : "c"
|
||||
},
|
||||
"args" : [ ]
|
||||
}
|
||||
} ]
|
||||
} ],
|
||||
"statements" : [ {
|
||||
"kind" : "ReturnStmt",
|
||||
"location" : [ 23, 5, 23, 14 ],
|
||||
"value" : {
|
||||
"kind" : "CallExpr",
|
||||
"location" : [ 23, 12, 23, 14 ],
|
||||
"function" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 23, 12, 23, 12 ],
|
||||
"name" : "b"
|
||||
},
|
||||
"args" : [ ]
|
||||
}
|
||||
} ]
|
||||
}, {
|
||||
"kind" : "FuncDef",
|
||||
"location" : [ 25, 1, 32, 3 ],
|
||||
"name" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 25, 5, 25, 5 ],
|
||||
"name" : "w"
|
||||
},
|
||||
"params" : [ ],
|
||||
"returnType" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 25, 8, 25, 8 ],
|
||||
"className" : "<None>"
|
||||
},
|
||||
"declarations" : [ {
|
||||
"kind" : "FuncDef",
|
||||
"location" : [ 26, 2, 31, 5 ],
|
||||
"name" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 26, 6, 26, 6 ],
|
||||
"name" : "x"
|
||||
},
|
||||
"params" : [ ],
|
||||
"returnType" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 26, 9, 26, 9 ],
|
||||
"className" : "<None>"
|
||||
},
|
||||
"declarations" : [ {
|
||||
"kind" : "FuncDef",
|
||||
"location" : [ 27, 4, 30, 8 ],
|
||||
"name" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 27, 8, 27, 8 ],
|
||||
"name" : "y"
|
||||
},
|
||||
"params" : [ ],
|
||||
"returnType" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 27, 11, 27, 11 ],
|
||||
"className" : "<None>"
|
||||
},
|
||||
"declarations" : [ {
|
||||
"kind" : "FuncDef",
|
||||
"location" : [ 28, 7, 29, 12 ],
|
||||
"name" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 28, 11, 28, 11 ],
|
||||
"name" : "z"
|
||||
},
|
||||
"params" : [ ],
|
||||
"returnType" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 28, 14, 28, 14 ],
|
||||
"className" : "<None>"
|
||||
},
|
||||
"declarations" : [ ],
|
||||
"statements" : [ {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 29, 11, 29, 11 ],
|
||||
"expr" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 29, 11, 29, 11 ],
|
||||
"value" : 4
|
||||
}
|
||||
} ]
|
||||
} ],
|
||||
"statements" : [ {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 30, 7, 30, 7 ],
|
||||
"expr" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 30, 7, 30, 7 ],
|
||||
"value" : 3
|
||||
}
|
||||
} ]
|
||||
} ],
|
||||
"statements" : [ {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 31, 4, 31, 4 ],
|
||||
"expr" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 31, 4, 31, 4 ],
|
||||
"value" : 2
|
||||
}
|
||||
} ]
|
||||
} ],
|
||||
"statements" : [ {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 32, 2, 32, 2 ],
|
||||
"expr" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 32, 2, 32, 2 ],
|
||||
"value" : 1
|
||||
}
|
||||
} ]
|
||||
}, {
|
||||
"kind" : "VarDef",
|
||||
"location" : [ 34, 1, 34, 78 ],
|
||||
"var" : {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 34, 1, 34, 71 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 34, 1, 34, 2 ],
|
||||
"name" : "xs"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ListType",
|
||||
"location" : [ 34, 5, 34, 71 ],
|
||||
"elementType" : {
|
||||
"kind" : "ListType",
|
||||
"location" : [ 34, 6, 34, 70 ],
|
||||
"elementType" : {
|
||||
"kind" : "ListType",
|
||||
"location" : [ 34, 7, 34, 69 ],
|
||||
"elementType" : {
|
||||
"kind" : "ListType",
|
||||
"location" : [ 34, 8, 34, 68 ],
|
||||
"elementType" : {
|
||||
"kind" : "ListType",
|
||||
"location" : [ 34, 9, 34, 67 ],
|
||||
"elementType" : {
|
||||
"kind" : "ListType",
|
||||
"location" : [ 34, 10, 34, 66 ],
|
||||
"elementType" : {
|
||||
"kind" : "ListType",
|
||||
"location" : [ 34, 11, 34, 65 ],
|
||||
"elementType" : {
|
||||
"kind" : "ListType",
|
||||
"location" : [ 34, 12, 34, 64 ],
|
||||
"elementType" : {
|
||||
"kind" : "ListType",
|
||||
"location" : [ 34, 13, 34, 63 ],
|
||||
"elementType" : {
|
||||
"kind" : "ListType",
|
||||
"location" : [ 34, 14, 34, 62 ],
|
||||
"elementType" : {
|
||||
"kind" : "ListType",
|
||||
"location" : [ 34, 15, 34, 61 ],
|
||||
"elementType" : {
|
||||
"kind" : "ListType",
|
||||
"location" : [ 34, 16, 34, 60 ],
|
||||
"elementType" : {
|
||||
"kind" : "ListType",
|
||||
"location" : [ 34, 17, 34, 59 ],
|
||||
"elementType" : {
|
||||
"kind" : "ListType",
|
||||
"location" : [ 34, 18, 34, 58 ],
|
||||
"elementType" : {
|
||||
"kind" : "ListType",
|
||||
"location" : [ 34, 19, 34, 57 ],
|
||||
"elementType" : {
|
||||
"kind" : "ListType",
|
||||
"location" : [ 34, 20, 34, 56 ],
|
||||
"elementType" : {
|
||||
"kind" : "ListType",
|
||||
"location" : [ 34, 21, 34, 55 ],
|
||||
"elementType" : {
|
||||
"kind" : "ListType",
|
||||
"location" : [ 34, 22, 34, 54 ],
|
||||
"elementType" : {
|
||||
"kind" : "ListType",
|
||||
"location" : [ 34, 23, 34, 53 ],
|
||||
"elementType" : {
|
||||
"kind" : "ListType",
|
||||
"location" : [ 34, 24, 34, 52 ],
|
||||
"elementType" : {
|
||||
"kind" : "ListType",
|
||||
"location" : [ 34, 25, 34, 51 ],
|
||||
"elementType" : {
|
||||
"kind" : "ListType",
|
||||
"location" : [ 34, 26, 34, 50 ],
|
||||
"elementType" : {
|
||||
"kind" : "ListType",
|
||||
"location" : [ 34, 27, 34, 49 ],
|
||||
"elementType" : {
|
||||
"kind" : "ListType",
|
||||
"location" : [ 34, 28, 34, 48 ],
|
||||
"elementType" : {
|
||||
"kind" : "ListType",
|
||||
"location" : [ 34, 29, 34, 47 ],
|
||||
"elementType" : {
|
||||
"kind" : "ListType",
|
||||
"location" : [ 34, 30, 34, 46 ],
|
||||
"elementType" : {
|
||||
"kind" : "ListType",
|
||||
"location" : [ 34, 31, 34, 45 ],
|
||||
"elementType" : {
|
||||
"kind" : "ListType",
|
||||
"location" : [ 34, 32, 34, 44 ],
|
||||
"elementType" : {
|
||||
"kind" : "ListType",
|
||||
"location" : [ 34, 33, 34, 43 ],
|
||||
"elementType" : {
|
||||
"kind" : "ListType",
|
||||
"location" : [ 34, 34, 34, 42 ],
|
||||
"elementType" : {
|
||||
"kind" : "ListType",
|
||||
"location" : [ 34, 35, 34, 41 ],
|
||||
"elementType" : {
|
||||
"kind" : "ListType",
|
||||
"location" : [ 34, 36, 34, 40 ],
|
||||
"elementType" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 34, 37, 34, 39 ],
|
||||
"className" : "int"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"value" : {
|
||||
"kind" : "NoneLiteral",
|
||||
"location" : [ 34, 75, 34, 78 ]
|
||||
}
|
||||
} ],
|
||||
"statements" : [ {
|
||||
"kind" : "AssignStmt",
|
||||
"location" : [ 35, 1, 35, 70 ],
|
||||
"targets" : [ {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 35, 1, 35, 2 ],
|
||||
"name" : "xs"
|
||||
} ],
|
||||
"value" : {
|
||||
"kind" : "ListExpr",
|
||||
"location" : [ 35, 6, 35, 70 ],
|
||||
"elements" : [ {
|
||||
"kind" : "ListExpr",
|
||||
"location" : [ 35, 7, 35, 69 ],
|
||||
"elements" : [ {
|
||||
"kind" : "ListExpr",
|
||||
"location" : [ 35, 8, 35, 68 ],
|
||||
"elements" : [ {
|
||||
"kind" : "ListExpr",
|
||||
"location" : [ 35, 9, 35, 67 ],
|
||||
"elements" : [ {
|
||||
"kind" : "ListExpr",
|
||||
"location" : [ 35, 10, 35, 66 ],
|
||||
"elements" : [ {
|
||||
"kind" : "ListExpr",
|
||||
"location" : [ 35, 11, 35, 65 ],
|
||||
"elements" : [ {
|
||||
"kind" : "ListExpr",
|
||||
"location" : [ 35, 12, 35, 64 ],
|
||||
"elements" : [ {
|
||||
"kind" : "ListExpr",
|
||||
"location" : [ 35, 13, 35, 63 ],
|
||||
"elements" : [ {
|
||||
"kind" : "ListExpr",
|
||||
"location" : [ 35, 14, 35, 62 ],
|
||||
"elements" : [ {
|
||||
"kind" : "ListExpr",
|
||||
"location" : [ 35, 15, 35, 61 ],
|
||||
"elements" : [ {
|
||||
"kind" : "ListExpr",
|
||||
"location" : [ 35, 16, 35, 60 ],
|
||||
"elements" : [ {
|
||||
"kind" : "ListExpr",
|
||||
"location" : [ 35, 17, 35, 59 ],
|
||||
"elements" : [ {
|
||||
"kind" : "ListExpr",
|
||||
"location" : [ 35, 18, 35, 58 ],
|
||||
"elements" : [ {
|
||||
"kind" : "ListExpr",
|
||||
"location" : [ 35, 19, 35, 57 ],
|
||||
"elements" : [ {
|
||||
"kind" : "ListExpr",
|
||||
"location" : [ 35, 20, 35, 56 ],
|
||||
"elements" : [ {
|
||||
"kind" : "ListExpr",
|
||||
"location" : [ 35, 21, 35, 55 ],
|
||||
"elements" : [ {
|
||||
"kind" : "ListExpr",
|
||||
"location" : [ 35, 22, 35, 54 ],
|
||||
"elements" : [ {
|
||||
"kind" : "ListExpr",
|
||||
"location" : [ 35, 23, 35, 53 ],
|
||||
"elements" : [ {
|
||||
"kind" : "ListExpr",
|
||||
"location" : [ 35, 24, 35, 52 ],
|
||||
"elements" : [ {
|
||||
"kind" : "ListExpr",
|
||||
"location" : [ 35, 25, 35, 51 ],
|
||||
"elements" : [ {
|
||||
"kind" : "ListExpr",
|
||||
"location" : [ 35, 26, 35, 50 ],
|
||||
"elements" : [ {
|
||||
"kind" : "ListExpr",
|
||||
"location" : [ 35, 27, 35, 49 ],
|
||||
"elements" : [ {
|
||||
"kind" : "ListExpr",
|
||||
"location" : [ 35, 28, 35, 48 ],
|
||||
"elements" : [ {
|
||||
"kind" : "ListExpr",
|
||||
"location" : [ 35, 29, 35, 47 ],
|
||||
"elements" : [ {
|
||||
"kind" : "ListExpr",
|
||||
"location" : [ 35, 30, 35, 46 ],
|
||||
"elements" : [ {
|
||||
"kind" : "ListExpr",
|
||||
"location" : [ 35, 31, 35, 45 ],
|
||||
"elements" : [ {
|
||||
"kind" : "ListExpr",
|
||||
"location" : [ 35, 32, 35, 44 ],
|
||||
"elements" : [ {
|
||||
"kind" : "ListExpr",
|
||||
"location" : [ 35, 33, 35, 43 ],
|
||||
"elements" : [ {
|
||||
"kind" : "ListExpr",
|
||||
"location" : [ 35, 34, 35, 42 ],
|
||||
"elements" : [ {
|
||||
"kind" : "ListExpr",
|
||||
"location" : [ 35, 35, 35, 41 ],
|
||||
"elements" : [ {
|
||||
"kind" : "ListExpr",
|
||||
"location" : [ 35, 36, 35, 40 ],
|
||||
"elements" : [ {
|
||||
"kind" : "ListExpr",
|
||||
"location" : [ 35, 37, 35, 39 ],
|
||||
"elements" : [ {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 35, 38, 35, 38 ],
|
||||
"value" : 1
|
||||
} ]
|
||||
} ]
|
||||
} ]
|
||||
} ]
|
||||
} ]
|
||||
} ]
|
||||
} ]
|
||||
} ]
|
||||
} ]
|
||||
} ]
|
||||
} ]
|
||||
} ]
|
||||
} ]
|
||||
} ]
|
||||
} ]
|
||||
} ]
|
||||
} ]
|
||||
} ]
|
||||
} ]
|
||||
} ]
|
||||
} ]
|
||||
} ]
|
||||
} ]
|
||||
} ]
|
||||
} ]
|
||||
} ]
|
||||
} ]
|
||||
} ]
|
||||
} ]
|
||||
} ]
|
||||
} ]
|
||||
} ]
|
||||
}
|
||||
}, {
|
||||
"kind" : "IfStmt",
|
||||
"location" : [ 37, 1, 46, 1 ],
|
||||
"condition" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 37, 4, 37, 4 ],
|
||||
"value" : 1
|
||||
},
|
||||
"thenBody" : [ {
|
||||
"kind" : "IfStmt",
|
||||
"location" : [ 38, 5, 44, 0 ],
|
||||
"condition" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 38, 8, 38, 8 ],
|
||||
"value" : 2
|
||||
},
|
||||
"thenBody" : [ {
|
||||
"kind" : "IfStmt",
|
||||
"location" : [ 39, 9, 44, 0 ],
|
||||
"condition" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 39, 12, 39, 12 ],
|
||||
"value" : 3
|
||||
},
|
||||
"thenBody" : [ {
|
||||
"kind" : "IfStmt",
|
||||
"location" : [ 40, 13, 42, 8 ],
|
||||
"condition" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 40, 16, 40, 16 ],
|
||||
"value" : 4
|
||||
},
|
||||
"thenBody" : [ {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 41, 17, 41, 20 ],
|
||||
"expr" : {
|
||||
"kind" : "BooleanLiteral",
|
||||
"location" : [ 41, 17, 41, 20 ],
|
||||
"value" : true
|
||||
}
|
||||
} ],
|
||||
"elseBody" : [ ]
|
||||
} ],
|
||||
"elseBody" : [ {
|
||||
"kind" : "IfStmt",
|
||||
"location" : [ 42, 9, 44, 0 ],
|
||||
"condition" : {
|
||||
"kind" : "UnaryExpr",
|
||||
"location" : [ 42, 14, 42, 15 ],
|
||||
"operator" : "-",
|
||||
"operand" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 42, 15, 42, 15 ],
|
||||
"value" : 3
|
||||
}
|
||||
},
|
||||
"thenBody" : [ {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 43, 13, 43, 17 ],
|
||||
"expr" : {
|
||||
"kind" : "BooleanLiteral",
|
||||
"location" : [ 43, 13, 43, 17 ],
|
||||
"value" : false
|
||||
}
|
||||
} ],
|
||||
"elseBody" : [ ]
|
||||
} ]
|
||||
} ],
|
||||
"elseBody" : [ ]
|
||||
} ],
|
||||
"elseBody" : [ {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 45, 5, 45, 9 ],
|
||||
"expr" : {
|
||||
"kind" : "BooleanLiteral",
|
||||
"location" : [ 45, 5, 45, 9 ],
|
||||
"value" : false
|
||||
}
|
||||
} ]
|
||||
} ],
|
||||
"errors" : {
|
||||
"errors" : [ ],
|
||||
"kind" : "Errors",
|
||||
"location" : [ 0, 0, 0, 0 ]
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
JAVA="java -cp pa1-tests/chocopy-ref.jar:target/assignment.jar chocopy.ChocoPy"
|
||||
|
||||
echo "# CORE TESTS"
|
||||
${JAVA} --pass=s --test --dir pa1-tests/core
|
||||
|
||||
echo
|
||||
echo "# EXTRA TESTS"
|
||||
${JAVA} --pass=s --test --dir pa1-tests/extra
|
||||
|
||||
echo
|
||||
echo "# STUDENT TESTS"
|
||||
function regen_ast_and_test {
|
||||
${JAVA} --pass=r "${1}" --out "${1}.ast" 2>/dev/null 1>&2
|
||||
${JAVA} --pass=s --test "${1}"
|
||||
}
|
||||
regen_ast_and_test src/test/data/pa1/student_contributed/good.py
|
||||
regen_ast_and_test src/test/data/pa1/student_contributed/bad.py
|
@ -0,0 +1,24 @@
|
||||
# Tests for PA2: ChocoPy Semantic Analysis
|
||||
|
||||
Clone a student repository:
|
||||
```
|
||||
TEAM="team"
|
||||
git clone --branch=pa2final \
|
||||
https://github.com/nyu-compiler-construction/pa2-chocopy-semantic-analysis-${TEAM}
|
||||
```
|
||||
|
||||
Build it:
|
||||
```
|
||||
cd pa2-chocopy-semantic-analysis-${TEAM}
|
||||
mvn clean package
|
||||
```
|
||||
|
||||
Clone the tests _into_ the student repository:
|
||||
```
|
||||
git clone https://github.com/nyu-compiler-construction/pa2-tests
|
||||
```
|
||||
|
||||
Run the tests:
|
||||
```
|
||||
./pa2-tests/run-tests.sh
|
||||
```
|
Binary file not shown.
@ -0,0 +1,38 @@
|
||||
count:int = 0
|
||||
|
||||
def foo(s: str) -> int:
|
||||
return len(s)
|
||||
|
||||
class bar(object):
|
||||
p: bool = True
|
||||
|
||||
def baz(self:"bar", xx: [int]) -> str:
|
||||
global count
|
||||
x:int = 0
|
||||
y:int = 1
|
||||
|
||||
def qux(y: int) -> object:
|
||||
nonlocal x
|
||||
if x > y:
|
||||
x = -1
|
||||
|
||||
for x in xx:
|
||||
self.p = x == 2
|
||||
|
||||
qux(0) # Yay! ChocoPy
|
||||
|
||||
count = count + 1
|
||||
|
||||
while x <= 0:
|
||||
if self.p:
|
||||
xx[0] = xx[1]
|
||||
self.p = not self.p
|
||||
x = x + 1
|
||||
elif foo("Long"[0]) == 1:
|
||||
self.p = self is None
|
||||
|
||||
return "Nope"
|
||||
|
||||
print(bar().baz([1,2]))
|
||||
|
||||
|
@ -0,0 +1,627 @@
|
||||
{
|
||||
"kind" : "Program",
|
||||
"location" : [ 1, 1, 36, 24 ],
|
||||
"declarations" : [ {
|
||||
"kind" : "VarDef",
|
||||
"location" : [ 1, 1, 1, 13 ],
|
||||
"var" : {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 1, 1, 1, 9 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 1, 1, 1, 5 ],
|
||||
"name" : "count"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 1, 7, 1, 9 ],
|
||||
"className" : "int"
|
||||
}
|
||||
},
|
||||
"value" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 1, 13, 1, 13 ],
|
||||
"value" : 0
|
||||
}
|
||||
}, {
|
||||
"kind" : "FuncDef",
|
||||
"location" : [ 3, 1, 4, 18 ],
|
||||
"name" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 3, 5, 3, 7 ],
|
||||
"name" : "foo"
|
||||
},
|
||||
"params" : [ {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 3, 9, 3, 14 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 3, 9, 3, 9 ],
|
||||
"name" : "s"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 3, 12, 3, 14 ],
|
||||
"className" : "str"
|
||||
}
|
||||
} ],
|
||||
"returnType" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 3, 20, 3, 22 ],
|
||||
"className" : "int"
|
||||
},
|
||||
"declarations" : [ ],
|
||||
"statements" : [ {
|
||||
"kind" : "ReturnStmt",
|
||||
"location" : [ 4, 5, 4, 17 ],
|
||||
"value" : {
|
||||
"kind" : "CallExpr",
|
||||
"location" : [ 4, 12, 4, 17 ],
|
||||
"function" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 4, 12, 4, 14 ],
|
||||
"name" : "len"
|
||||
},
|
||||
"args" : [ {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 4, 16, 4, 16 ],
|
||||
"name" : "s"
|
||||
} ]
|
||||
}
|
||||
} ]
|
||||
}, {
|
||||
"kind" : "ClassDef",
|
||||
"location" : [ 6, 1, 36, 0 ],
|
||||
"name" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 6, 7, 6, 9 ],
|
||||
"name" : "bar"
|
||||
},
|
||||
"superClass" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 6, 11, 6, 16 ],
|
||||
"name" : "object"
|
||||
},
|
||||
"declarations" : [ {
|
||||
"kind" : "VarDef",
|
||||
"location" : [ 7, 5, 7, 18 ],
|
||||
"var" : {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 7, 5, 7, 11 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 7, 5, 7, 5 ],
|
||||
"name" : "p"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 7, 8, 7, 11 ],
|
||||
"className" : "bool"
|
||||
}
|
||||
},
|
||||
"value" : {
|
||||
"kind" : "BooleanLiteral",
|
||||
"location" : [ 7, 15, 7, 18 ],
|
||||
"value" : true
|
||||
}
|
||||
}, {
|
||||
"kind" : "FuncDef",
|
||||
"location" : [ 9, 5, 34, 22 ],
|
||||
"name" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 9, 9, 9, 11 ],
|
||||
"name" : "baz"
|
||||
},
|
||||
"params" : [ {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 9, 13, 9, 22 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 9, 13, 9, 16 ],
|
||||
"name" : "self"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 9, 18, 9, 22 ],
|
||||
"className" : "bar"
|
||||
}
|
||||
}, {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 9, 25, 9, 33 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 9, 25, 9, 26 ],
|
||||
"name" : "xx"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ListType",
|
||||
"location" : [ 9, 29, 9, 33 ],
|
||||
"elementType" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 9, 30, 9, 32 ],
|
||||
"className" : "int"
|
||||
}
|
||||
}
|
||||
} ],
|
||||
"returnType" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 9, 39, 9, 41 ],
|
||||
"className" : "str"
|
||||
},
|
||||
"declarations" : [ {
|
||||
"kind" : "GlobalDecl",
|
||||
"location" : [ 10, 9, 10, 20 ],
|
||||
"variable" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 10, 16, 10, 20 ],
|
||||
"name" : "count"
|
||||
}
|
||||
}, {
|
||||
"kind" : "VarDef",
|
||||
"location" : [ 11, 9, 11, 17 ],
|
||||
"var" : {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 11, 9, 11, 13 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 11, 9, 11, 9 ],
|
||||
"name" : "x"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 11, 11, 11, 13 ],
|
||||
"className" : "int"
|
||||
}
|
||||
},
|
||||
"value" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 11, 17, 11, 17 ],
|
||||
"value" : 0
|
||||
}
|
||||
}, {
|
||||
"kind" : "VarDef",
|
||||
"location" : [ 12, 9, 12, 17 ],
|
||||
"var" : {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 12, 9, 12, 13 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 12, 9, 12, 9 ],
|
||||
"name" : "y"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 12, 11, 12, 13 ],
|
||||
"className" : "int"
|
||||
}
|
||||
},
|
||||
"value" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 12, 17, 12, 17 ],
|
||||
"value" : 1
|
||||
}
|
||||
}, {
|
||||
"kind" : "FuncDef",
|
||||
"location" : [ 14, 9, 19, 8 ],
|
||||
"name" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 14, 13, 14, 15 ],
|
||||
"name" : "qux"
|
||||
},
|
||||
"params" : [ {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 14, 17, 14, 22 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 14, 17, 14, 17 ],
|
||||
"name" : "y"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 14, 20, 14, 22 ],
|
||||
"className" : "int"
|
||||
}
|
||||
} ],
|
||||
"returnType" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 14, 28, 14, 33 ],
|
||||
"className" : "object"
|
||||
},
|
||||
"declarations" : [ {
|
||||
"kind" : "NonLocalDecl",
|
||||
"location" : [ 15, 13, 15, 22 ],
|
||||
"variable" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 15, 22, 15, 22 ],
|
||||
"name" : "x"
|
||||
}
|
||||
} ],
|
||||
"statements" : [ {
|
||||
"kind" : "IfStmt",
|
||||
"location" : [ 16, 13, 19, 8 ],
|
||||
"condition" : {
|
||||
"kind" : "BinaryExpr",
|
||||
"location" : [ 16, 16, 16, 20 ],
|
||||
"left" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 16, 16, 16, 16 ],
|
||||
"name" : "x"
|
||||
},
|
||||
"operator" : ">",
|
||||
"right" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 16, 20, 16, 20 ],
|
||||
"name" : "y"
|
||||
}
|
||||
},
|
||||
"thenBody" : [ {
|
||||
"kind" : "AssignStmt",
|
||||
"location" : [ 17, 17, 17, 22 ],
|
||||
"targets" : [ {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 17, 17, 17, 17 ],
|
||||
"name" : "x"
|
||||
} ],
|
||||
"value" : {
|
||||
"kind" : "UnaryExpr",
|
||||
"location" : [ 17, 21, 17, 22 ],
|
||||
"operator" : "-",
|
||||
"operand" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 17, 22, 17, 22 ],
|
||||
"value" : 1
|
||||
}
|
||||
}
|
||||
} ],
|
||||
"elseBody" : [ ]
|
||||
} ]
|
||||
} ],
|
||||
"statements" : [ {
|
||||
"kind" : "ForStmt",
|
||||
"location" : [ 19, 9, 22, 8 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 19, 13, 19, 13 ],
|
||||
"name" : "x"
|
||||
},
|
||||
"iterable" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 19, 18, 19, 19 ],
|
||||
"name" : "xx"
|
||||
},
|
||||
"body" : [ {
|
||||
"kind" : "AssignStmt",
|
||||
"location" : [ 20, 13, 20, 27 ],
|
||||
"targets" : [ {
|
||||
"kind" : "MemberExpr",
|
||||
"location" : [ 20, 13, 20, 18 ],
|
||||
"object" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 20, 13, 20, 16 ],
|
||||
"name" : "self"
|
||||
},
|
||||
"member" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 20, 18, 20, 18 ],
|
||||
"name" : "p"
|
||||
}
|
||||
} ],
|
||||
"value" : {
|
||||
"kind" : "BinaryExpr",
|
||||
"location" : [ 20, 22, 20, 27 ],
|
||||
"left" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 20, 22, 20, 22 ],
|
||||
"name" : "x"
|
||||
},
|
||||
"operator" : "==",
|
||||
"right" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 20, 27, 20, 27 ],
|
||||
"value" : 2
|
||||
}
|
||||
}
|
||||
} ]
|
||||
}, {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 22, 9, 22, 14 ],
|
||||
"expr" : {
|
||||
"kind" : "CallExpr",
|
||||
"location" : [ 22, 9, 22, 14 ],
|
||||
"function" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 22, 9, 22, 11 ],
|
||||
"name" : "qux"
|
||||
},
|
||||
"args" : [ {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 22, 13, 22, 13 ],
|
||||
"value" : 0
|
||||
} ]
|
||||
}
|
||||
}, {
|
||||
"kind" : "AssignStmt",
|
||||
"location" : [ 24, 9, 24, 25 ],
|
||||
"targets" : [ {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 24, 9, 24, 13 ],
|
||||
"name" : "count"
|
||||
} ],
|
||||
"value" : {
|
||||
"kind" : "BinaryExpr",
|
||||
"location" : [ 24, 17, 24, 25 ],
|
||||
"left" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 24, 17, 24, 21 ],
|
||||
"name" : "count"
|
||||
},
|
||||
"operator" : "+",
|
||||
"right" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 24, 25, 24, 25 ],
|
||||
"value" : 1
|
||||
}
|
||||
}
|
||||
}, {
|
||||
"kind" : "WhileStmt",
|
||||
"location" : [ 26, 9, 34, 8 ],
|
||||
"condition" : {
|
||||
"kind" : "BinaryExpr",
|
||||
"location" : [ 26, 15, 26, 20 ],
|
||||
"left" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 26, 15, 26, 15 ],
|
||||
"name" : "x"
|
||||
},
|
||||
"operator" : "<=",
|
||||
"right" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 26, 20, 26, 20 ],
|
||||
"value" : 0
|
||||
}
|
||||
},
|
||||
"body" : [ {
|
||||
"kind" : "IfStmt",
|
||||
"location" : [ 27, 13, 34, 8 ],
|
||||
"condition" : {
|
||||
"kind" : "MemberExpr",
|
||||
"location" : [ 27, 16, 27, 21 ],
|
||||
"object" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 27, 16, 27, 19 ],
|
||||
"name" : "self"
|
||||
},
|
||||
"member" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 27, 21, 27, 21 ],
|
||||
"name" : "p"
|
||||
}
|
||||
},
|
||||
"thenBody" : [ {
|
||||
"kind" : "AssignStmt",
|
||||
"location" : [ 28, 17, 28, 29 ],
|
||||
"targets" : [ {
|
||||
"kind" : "IndexExpr",
|
||||
"location" : [ 28, 17, 28, 21 ],
|
||||
"list" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 28, 17, 28, 18 ],
|
||||
"name" : "xx"
|
||||
},
|
||||
"index" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 28, 20, 28, 20 ],
|
||||
"value" : 0
|
||||
}
|
||||
} ],
|
||||
"value" : {
|
||||
"kind" : "IndexExpr",
|
||||
"location" : [ 28, 25, 28, 29 ],
|
||||
"list" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 28, 25, 28, 26 ],
|
||||
"name" : "xx"
|
||||
},
|
||||
"index" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 28, 28, 28, 28 ],
|
||||
"value" : 1
|
||||
}
|
||||
}
|
||||
}, {
|
||||
"kind" : "AssignStmt",
|
||||
"location" : [ 29, 17, 29, 35 ],
|
||||
"targets" : [ {
|
||||
"kind" : "MemberExpr",
|
||||
"location" : [ 29, 17, 29, 22 ],
|
||||
"object" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 29, 17, 29, 20 ],
|
||||
"name" : "self"
|
||||
},
|
||||
"member" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 29, 22, 29, 22 ],
|
||||
"name" : "p"
|
||||
}
|
||||
} ],
|
||||
"value" : {
|
||||
"kind" : "UnaryExpr",
|
||||
"location" : [ 29, 26, 29, 35 ],
|
||||
"operator" : "not",
|
||||
"operand" : {
|
||||
"kind" : "MemberExpr",
|
||||
"location" : [ 29, 30, 29, 35 ],
|
||||
"object" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 29, 30, 29, 33 ],
|
||||
"name" : "self"
|
||||
},
|
||||
"member" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 29, 35, 29, 35 ],
|
||||
"name" : "p"
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
"kind" : "AssignStmt",
|
||||
"location" : [ 30, 17, 30, 25 ],
|
||||
"targets" : [ {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 30, 17, 30, 17 ],
|
||||
"name" : "x"
|
||||
} ],
|
||||
"value" : {
|
||||
"kind" : "BinaryExpr",
|
||||
"location" : [ 30, 21, 30, 25 ],
|
||||
"left" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 30, 21, 30, 21 ],
|
||||
"name" : "x"
|
||||
},
|
||||
"operator" : "+",
|
||||
"right" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 30, 25, 30, 25 ],
|
||||
"value" : 1
|
||||
}
|
||||
}
|
||||
} ],
|
||||
"elseBody" : [ {
|
||||
"kind" : "IfStmt",
|
||||
"location" : [ 31, 13, 34, 8 ],
|
||||
"condition" : {
|
||||
"kind" : "BinaryExpr",
|
||||
"location" : [ 31, 18, 31, 36 ],
|
||||
"left" : {
|
||||
"kind" : "CallExpr",
|
||||
"location" : [ 31, 18, 31, 31 ],
|
||||
"function" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 31, 18, 31, 20 ],
|
||||
"name" : "foo"
|
||||
},
|
||||
"args" : [ {
|
||||
"kind" : "IndexExpr",
|
||||
"location" : [ 31, 22, 31, 30 ],
|
||||
"list" : {
|
||||
"kind" : "StringLiteral",
|
||||
"location" : [ 31, 22, 31, 27 ],
|
||||
"value" : "Long"
|
||||
},
|
||||
"index" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 31, 29, 31, 29 ],
|
||||
"value" : 0
|
||||
}
|
||||
} ]
|
||||
},
|
||||
"operator" : "==",
|
||||
"right" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 31, 36, 31, 36 ],
|
||||
"value" : 1
|
||||
}
|
||||
},
|
||||
"thenBody" : [ {
|
||||
"kind" : "AssignStmt",
|
||||
"location" : [ 32, 17, 32, 37 ],
|
||||
"targets" : [ {
|
||||
"kind" : "MemberExpr",
|
||||
"location" : [ 32, 17, 32, 22 ],
|
||||
"object" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 32, 17, 32, 20 ],
|
||||
"name" : "self"
|
||||
},
|
||||
"member" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 32, 22, 32, 22 ],
|
||||
"name" : "p"
|
||||
}
|
||||
} ],
|
||||
"value" : {
|
||||
"kind" : "BinaryExpr",
|
||||
"location" : [ 32, 26, 32, 37 ],
|
||||
"left" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 32, 26, 32, 29 ],
|
||||
"name" : "self"
|
||||
},
|
||||
"operator" : "is",
|
||||
"right" : {
|
||||
"kind" : "NoneLiteral",
|
||||
"location" : [ 32, 34, 32, 37 ]
|
||||
}
|
||||
}
|
||||
} ],
|
||||
"elseBody" : [ ]
|
||||
} ]
|
||||
} ]
|
||||
}, {
|
||||
"kind" : "ReturnStmt",
|
||||
"location" : [ 34, 9, 34, 21 ],
|
||||
"value" : {
|
||||
"kind" : "StringLiteral",
|
||||
"location" : [ 34, 16, 34, 21 ],
|
||||
"value" : "Nope"
|
||||
}
|
||||
} ]
|
||||
} ]
|
||||
} ],
|
||||
"statements" : [ {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 36, 1, 36, 23 ],
|
||||
"expr" : {
|
||||
"kind" : "CallExpr",
|
||||
"location" : [ 36, 1, 36, 23 ],
|
||||
"function" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 36, 1, 36, 5 ],
|
||||
"name" : "print"
|
||||
},
|
||||
"args" : [ {
|
||||
"kind" : "MethodCallExpr",
|
||||
"location" : [ 36, 7, 36, 22 ],
|
||||
"method" : {
|
||||
"kind" : "MemberExpr",
|
||||
"location" : [ 36, 7, 36, 15 ],
|
||||
"object" : {
|
||||
"kind" : "CallExpr",
|
||||
"location" : [ 36, 7, 36, 11 ],
|
||||
"function" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 36, 7, 36, 9 ],
|
||||
"name" : "bar"
|
||||
},
|
||||
"args" : [ ]
|
||||
},
|
||||
"member" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 36, 13, 36, 15 ],
|
||||
"name" : "baz"
|
||||
}
|
||||
},
|
||||
"args" : [ {
|
||||
"kind" : "ListExpr",
|
||||
"location" : [ 36, 17, 36, 21 ],
|
||||
"elements" : [ {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 36, 18, 36, 18 ],
|
||||
"value" : 1
|
||||
}, {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 36, 20, 36, 20 ],
|
||||
"value" : 2
|
||||
} ]
|
||||
} ]
|
||||
} ]
|
||||
}
|
||||
} ],
|
||||
"errors" : {
|
||||
"errors" : [ ],
|
||||
"kind" : "Errors",
|
||||
"location" : [ 0, 0, 0, 0 ]
|
||||
}
|
||||
}
|
@ -0,0 +1,952 @@
|
||||
{
|
||||
"kind" : "Program",
|
||||
"location" : [ 1, 1, 36, 24 ],
|
||||
"declarations" : [ {
|
||||
"kind" : "VarDef",
|
||||
"location" : [ 1, 1, 1, 13 ],
|
||||
"var" : {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 1, 1, 1, 9 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 1, 1, 1, 5 ],
|
||||
"name" : "count"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 1, 7, 1, 9 ],
|
||||
"className" : "int"
|
||||
}
|
||||
},
|
||||
"value" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 1, 13, 1, 13 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "int"
|
||||
},
|
||||
"value" : 0
|
||||
}
|
||||
}, {
|
||||
"kind" : "FuncDef",
|
||||
"location" : [ 3, 1, 4, 18 ],
|
||||
"name" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 3, 5, 3, 7 ],
|
||||
"name" : "foo"
|
||||
},
|
||||
"params" : [ {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 3, 9, 3, 14 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 3, 9, 3, 9 ],
|
||||
"name" : "s"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 3, 12, 3, 14 ],
|
||||
"className" : "str"
|
||||
}
|
||||
} ],
|
||||
"returnType" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 3, 20, 3, 22 ],
|
||||
"className" : "int"
|
||||
},
|
||||
"declarations" : [ ],
|
||||
"statements" : [ {
|
||||
"kind" : "ReturnStmt",
|
||||
"location" : [ 4, 5, 4, 17 ],
|
||||
"value" : {
|
||||
"kind" : "CallExpr",
|
||||
"location" : [ 4, 12, 4, 17 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "int"
|
||||
},
|
||||
"function" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 4, 12, 4, 14 ],
|
||||
"inferredType" : {
|
||||
"kind" : "FuncType",
|
||||
"parameters" : [ {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "object"
|
||||
} ],
|
||||
"returnType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "int"
|
||||
}
|
||||
},
|
||||
"name" : "len"
|
||||
},
|
||||
"args" : [ {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 4, 16, 4, 16 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "str"
|
||||
},
|
||||
"name" : "s"
|
||||
} ]
|
||||
}
|
||||
} ]
|
||||
}, {
|
||||
"kind" : "ClassDef",
|
||||
"location" : [ 6, 1, 36, 0 ],
|
||||
"name" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 6, 7, 6, 9 ],
|
||||
"name" : "bar"
|
||||
},
|
||||
"superClass" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 6, 11, 6, 16 ],
|
||||
"name" : "object"
|
||||
},
|
||||
"declarations" : [ {
|
||||
"kind" : "VarDef",
|
||||
"location" : [ 7, 5, 7, 18 ],
|
||||
"var" : {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 7, 5, 7, 11 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 7, 5, 7, 5 ],
|
||||
"name" : "p"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 7, 8, 7, 11 ],
|
||||
"className" : "bool"
|
||||
}
|
||||
},
|
||||
"value" : {
|
||||
"kind" : "BooleanLiteral",
|
||||
"location" : [ 7, 15, 7, 18 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "bool"
|
||||
},
|
||||
"value" : true
|
||||
}
|
||||
}, {
|
||||
"kind" : "FuncDef",
|
||||
"location" : [ 9, 5, 34, 22 ],
|
||||
"name" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 9, 9, 9, 11 ],
|
||||
"name" : "baz"
|
||||
},
|
||||
"params" : [ {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 9, 13, 9, 22 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 9, 13, 9, 16 ],
|
||||
"name" : "self"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 9, 18, 9, 22 ],
|
||||
"className" : "bar"
|
||||
}
|
||||
}, {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 9, 25, 9, 33 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 9, 25, 9, 26 ],
|
||||
"name" : "xx"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ListType",
|
||||
"location" : [ 9, 29, 9, 33 ],
|
||||
"elementType" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 9, 30, 9, 32 ],
|
||||
"className" : "int"
|
||||
}
|
||||
}
|
||||
} ],
|
||||
"returnType" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 9, 39, 9, 41 ],
|
||||
"className" : "str"
|
||||
},
|
||||
"declarations" : [ {
|
||||
"kind" : "GlobalDecl",
|
||||
"location" : [ 10, 9, 10, 20 ],
|
||||
"variable" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 10, 16, 10, 20 ],
|
||||
"name" : "count"
|
||||
}
|
||||
}, {
|
||||
"kind" : "VarDef",
|
||||
"location" : [ 11, 9, 11, 17 ],
|
||||
"var" : {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 11, 9, 11, 13 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 11, 9, 11, 9 ],
|
||||
"name" : "x"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 11, 11, 11, 13 ],
|
||||
"className" : "int"
|
||||
}
|
||||
},
|
||||
"value" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 11, 17, 11, 17 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "int"
|
||||
},
|
||||
"value" : 0
|
||||
}
|
||||
}, {
|
||||
"kind" : "VarDef",
|
||||
"location" : [ 12, 9, 12, 17 ],
|
||||
"var" : {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 12, 9, 12, 13 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 12, 9, 12, 9 ],
|
||||
"name" : "y"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 12, 11, 12, 13 ],
|
||||
"className" : "int"
|
||||
}
|
||||
},
|
||||
"value" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 12, 17, 12, 17 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "int"
|
||||
},
|
||||
"value" : 1
|
||||
}
|
||||
}, {
|
||||
"kind" : "FuncDef",
|
||||
"location" : [ 14, 9, 19, 8 ],
|
||||
"name" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 14, 13, 14, 15 ],
|
||||
"name" : "qux"
|
||||
},
|
||||
"params" : [ {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 14, 17, 14, 22 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 14, 17, 14, 17 ],
|
||||
"name" : "y"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 14, 20, 14, 22 ],
|
||||
"className" : "int"
|
||||
}
|
||||
} ],
|
||||
"returnType" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 14, 28, 14, 33 ],
|
||||
"className" : "object"
|
||||
},
|
||||
"declarations" : [ {
|
||||
"kind" : "NonLocalDecl",
|
||||
"location" : [ 15, 13, 15, 22 ],
|
||||
"variable" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 15, 22, 15, 22 ],
|
||||
"name" : "x"
|
||||
}
|
||||
} ],
|
||||
"statements" : [ {
|
||||
"kind" : "IfStmt",
|
||||
"location" : [ 16, 13, 19, 8 ],
|
||||
"condition" : {
|
||||
"kind" : "BinaryExpr",
|
||||
"location" : [ 16, 16, 16, 20 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "bool"
|
||||
},
|
||||
"left" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 16, 16, 16, 16 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "int"
|
||||
},
|
||||
"name" : "x"
|
||||
},
|
||||
"operator" : ">",
|
||||
"right" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 16, 20, 16, 20 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "int"
|
||||
},
|
||||
"name" : "y"
|
||||
}
|
||||
},
|
||||
"thenBody" : [ {
|
||||
"kind" : "AssignStmt",
|
||||
"location" : [ 17, 17, 17, 22 ],
|
||||
"targets" : [ {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 17, 17, 17, 17 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "int"
|
||||
},
|
||||
"name" : "x"
|
||||
} ],
|
||||
"value" : {
|
||||
"kind" : "UnaryExpr",
|
||||
"location" : [ 17, 21, 17, 22 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "int"
|
||||
},
|
||||
"operator" : "-",
|
||||
"operand" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 17, 22, 17, 22 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "int"
|
||||
},
|
||||
"value" : 1
|
||||
}
|
||||
}
|
||||
} ],
|
||||
"elseBody" : [ ]
|
||||
} ]
|
||||
} ],
|
||||
"statements" : [ {
|
||||
"kind" : "ForStmt",
|
||||
"location" : [ 19, 9, 22, 8 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 19, 13, 19, 13 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "int"
|
||||
},
|
||||
"name" : "x"
|
||||
},
|
||||
"iterable" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 19, 18, 19, 19 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ListValueType",
|
||||
"elementType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "int"
|
||||
}
|
||||
},
|
||||
"name" : "xx"
|
||||
},
|
||||
"body" : [ {
|
||||
"kind" : "AssignStmt",
|
||||
"location" : [ 20, 13, 20, 27 ],
|
||||
"targets" : [ {
|
||||
"kind" : "MemberExpr",
|
||||
"location" : [ 20, 13, 20, 18 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "bool"
|
||||
},
|
||||
"object" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 20, 13, 20, 16 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "bar"
|
||||
},
|
||||
"name" : "self"
|
||||
},
|
||||
"member" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 20, 18, 20, 18 ],
|
||||
"name" : "p"
|
||||
}
|
||||
} ],
|
||||
"value" : {
|
||||
"kind" : "BinaryExpr",
|
||||
"location" : [ 20, 22, 20, 27 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "bool"
|
||||
},
|
||||
"left" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 20, 22, 20, 22 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "int"
|
||||
},
|
||||
"name" : "x"
|
||||
},
|
||||
"operator" : "==",
|
||||
"right" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 20, 27, 20, 27 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "int"
|
||||
},
|
||||
"value" : 2
|
||||
}
|
||||
}
|
||||
} ]
|
||||
}, {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 22, 9, 22, 14 ],
|
||||
"expr" : {
|
||||
"kind" : "CallExpr",
|
||||
"location" : [ 22, 9, 22, 14 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "object"
|
||||
},
|
||||
"function" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 22, 9, 22, 11 ],
|
||||
"inferredType" : {
|
||||
"kind" : "FuncType",
|
||||
"parameters" : [ {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "int"
|
||||
} ],
|
||||
"returnType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "object"
|
||||
}
|
||||
},
|
||||
"name" : "qux"
|
||||
},
|
||||
"args" : [ {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 22, 13, 22, 13 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "int"
|
||||
},
|
||||
"value" : 0
|
||||
} ]
|
||||
}
|
||||
}, {
|
||||
"kind" : "AssignStmt",
|
||||
"location" : [ 24, 9, 24, 25 ],
|
||||
"targets" : [ {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 24, 9, 24, 13 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "int"
|
||||
},
|
||||
"name" : "count"
|
||||
} ],
|
||||
"value" : {
|
||||
"kind" : "BinaryExpr",
|
||||
"location" : [ 24, 17, 24, 25 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "int"
|
||||
},
|
||||
"left" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 24, 17, 24, 21 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "int"
|
||||
},
|
||||
"name" : "count"
|
||||
},
|
||||
"operator" : "+",
|
||||
"right" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 24, 25, 24, 25 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "int"
|
||||
},
|
||||
"value" : 1
|
||||
}
|
||||
}
|
||||
}, {
|
||||
"kind" : "WhileStmt",
|
||||
"location" : [ 26, 9, 34, 8 ],
|
||||
"condition" : {
|
||||
"kind" : "BinaryExpr",
|
||||
"location" : [ 26, 15, 26, 20 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "bool"
|
||||
},
|
||||
"left" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 26, 15, 26, 15 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "int"
|
||||
},
|
||||
"name" : "x"
|
||||
},
|
||||
"operator" : "<=",
|
||||
"right" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 26, 20, 26, 20 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "int"
|
||||
},
|
||||
"value" : 0
|
||||
}
|
||||
},
|
||||
"body" : [ {
|
||||
"kind" : "IfStmt",
|
||||
"location" : [ 27, 13, 34, 8 ],
|
||||
"condition" : {
|
||||
"kind" : "MemberExpr",
|
||||
"location" : [ 27, 16, 27, 21 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "bool"
|
||||
},
|
||||
"object" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 27, 16, 27, 19 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "bar"
|
||||
},
|
||||
"name" : "self"
|
||||
},
|
||||
"member" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 27, 21, 27, 21 ],
|
||||
"name" : "p"
|
||||
}
|
||||
},
|
||||
"thenBody" : [ {
|
||||
"kind" : "AssignStmt",
|
||||
"location" : [ 28, 17, 28, 29 ],
|
||||
"targets" : [ {
|
||||
"kind" : "IndexExpr",
|
||||
"location" : [ 28, 17, 28, 21 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "int"
|
||||
},
|
||||
"list" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 28, 17, 28, 18 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ListValueType",
|
||||
"elementType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "int"
|
||||
}
|
||||
},
|
||||
"name" : "xx"
|
||||
},
|
||||
"index" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 28, 20, 28, 20 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "int"
|
||||
},
|
||||
"value" : 0
|
||||
}
|
||||
} ],
|
||||
"value" : {
|
||||
"kind" : "IndexExpr",
|
||||
"location" : [ 28, 25, 28, 29 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "int"
|
||||
},
|
||||
"list" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 28, 25, 28, 26 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ListValueType",
|
||||
"elementType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "int"
|
||||
}
|
||||
},
|
||||
"name" : "xx"
|
||||
},
|
||||
"index" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 28, 28, 28, 28 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "int"
|
||||
},
|
||||
"value" : 1
|
||||
}
|
||||
}
|
||||
}, {
|
||||
"kind" : "AssignStmt",
|
||||
"location" : [ 29, 17, 29, 35 ],
|
||||
"targets" : [ {
|
||||
"kind" : "MemberExpr",
|
||||
"location" : [ 29, 17, 29, 22 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "bool"
|
||||
},
|
||||
"object" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 29, 17, 29, 20 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "bar"
|
||||
},
|
||||
"name" : "self"
|
||||
},
|
||||
"member" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 29, 22, 29, 22 ],
|
||||
"name" : "p"
|
||||
}
|
||||
} ],
|
||||
"value" : {
|
||||
"kind" : "UnaryExpr",
|
||||
"location" : [ 29, 26, 29, 35 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "bool"
|
||||
},
|
||||
"operator" : "not",
|
||||
"operand" : {
|
||||
"kind" : "MemberExpr",
|
||||
"location" : [ 29, 30, 29, 35 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "bool"
|
||||
},
|
||||
"object" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 29, 30, 29, 33 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "bar"
|
||||
},
|
||||
"name" : "self"
|
||||
},
|
||||
"member" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 29, 35, 29, 35 ],
|
||||
"name" : "p"
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
"kind" : "AssignStmt",
|
||||
"location" : [ 30, 17, 30, 25 ],
|
||||
"targets" : [ {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 30, 17, 30, 17 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "int"
|
||||
},
|
||||
"name" : "x"
|
||||
} ],
|
||||
"value" : {
|
||||
"kind" : "BinaryExpr",
|
||||
"location" : [ 30, 21, 30, 25 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "int"
|
||||
},
|
||||
"left" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 30, 21, 30, 21 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "int"
|
||||
},
|
||||
"name" : "x"
|
||||
},
|
||||
"operator" : "+",
|
||||
"right" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 30, 25, 30, 25 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "int"
|
||||
},
|
||||
"value" : 1
|
||||
}
|
||||
}
|
||||
} ],
|
||||
"elseBody" : [ {
|
||||
"kind" : "IfStmt",
|
||||
"location" : [ 31, 13, 34, 8 ],
|
||||
"condition" : {
|
||||
"kind" : "BinaryExpr",
|
||||
"location" : [ 31, 18, 31, 36 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "bool"
|
||||
},
|
||||
"left" : {
|
||||
"kind" : "CallExpr",
|
||||
"location" : [ 31, 18, 31, 31 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "int"
|
||||
},
|
||||
"function" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 31, 18, 31, 20 ],
|
||||
"inferredType" : {
|
||||
"kind" : "FuncType",
|
||||
"parameters" : [ {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "str"
|
||||
} ],
|
||||
"returnType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "int"
|
||||
}
|
||||
},
|
||||
"name" : "foo"
|
||||
},
|
||||
"args" : [ {
|
||||
"kind" : "IndexExpr",
|
||||
"location" : [ 31, 22, 31, 30 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "str"
|
||||
},
|
||||
"list" : {
|
||||
"kind" : "StringLiteral",
|
||||
"location" : [ 31, 22, 31, 27 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "str"
|
||||
},
|
||||
"value" : "Long"
|
||||
},
|
||||
"index" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 31, 29, 31, 29 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "int"
|
||||
},
|
||||
"value" : 0
|
||||
}
|
||||
} ]
|
||||
},
|
||||
"operator" : "==",
|
||||
"right" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 31, 36, 31, 36 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "int"
|
||||
},
|
||||
"value" : 1
|
||||
}
|
||||
},
|
||||
"thenBody" : [ {
|
||||
"kind" : "AssignStmt",
|
||||
"location" : [ 32, 17, 32, 37 ],
|
||||
"targets" : [ {
|
||||
"kind" : "MemberExpr",
|
||||
"location" : [ 32, 17, 32, 22 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "bool"
|
||||
},
|
||||
"object" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 32, 17, 32, 20 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "bar"
|
||||
},
|
||||
"name" : "self"
|
||||
},
|
||||
"member" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 32, 22, 32, 22 ],
|
||||
"name" : "p"
|
||||
}
|
||||
} ],
|
||||
"value" : {
|
||||
"kind" : "BinaryExpr",
|
||||
"location" : [ 32, 26, 32, 37 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "bool"
|
||||
},
|
||||
"left" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 32, 26, 32, 29 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "bar"
|
||||
},
|
||||
"name" : "self"
|
||||
},
|
||||
"operator" : "is",
|
||||
"right" : {
|
||||
"kind" : "NoneLiteral",
|
||||
"location" : [ 32, 34, 32, 37 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "<None>"
|
||||
}
|
||||
}
|
||||
}
|
||||
} ],
|
||||
"elseBody" : [ ]
|
||||
} ]
|
||||
} ]
|
||||
}, {
|
||||
"kind" : "ReturnStmt",
|
||||
"location" : [ 34, 9, 34, 21 ],
|
||||
"value" : {
|
||||
"kind" : "StringLiteral",
|
||||
"location" : [ 34, 16, 34, 21 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "str"
|
||||
},
|
||||
"value" : "Nope"
|
||||
}
|
||||
} ]
|
||||
} ]
|
||||
} ],
|
||||
"statements" : [ {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 36, 1, 36, 23 ],
|
||||
"expr" : {
|
||||
"kind" : "CallExpr",
|
||||
"location" : [ 36, 1, 36, 23 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "<None>"
|
||||
},
|
||||
"function" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 36, 1, 36, 5 ],
|
||||
"inferredType" : {
|
||||
"kind" : "FuncType",
|
||||
"parameters" : [ {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "object"
|
||||
} ],
|
||||
"returnType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "<None>"
|
||||
}
|
||||
},
|
||||
"name" : "print"
|
||||
},
|
||||
"args" : [ {
|
||||
"kind" : "MethodCallExpr",
|
||||
"location" : [ 36, 7, 36, 22 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "str"
|
||||
},
|
||||
"method" : {
|
||||
"kind" : "MemberExpr",
|
||||
"location" : [ 36, 7, 36, 15 ],
|
||||
"inferredType" : {
|
||||
"kind" : "FuncType",
|
||||
"parameters" : [ {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "bar"
|
||||
}, {
|
||||
"kind" : "ListValueType",
|
||||
"elementType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "int"
|
||||
}
|
||||
} ],
|
||||
"returnType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "str"
|
||||
}
|
||||
},
|
||||
"object" : {
|
||||
"kind" : "CallExpr",
|
||||
"location" : [ 36, 7, 36, 11 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "bar"
|
||||
},
|
||||
"function" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 36, 7, 36, 9 ],
|
||||
"name" : "bar"
|
||||
},
|
||||
"args" : [ ]
|
||||
},
|
||||
"member" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 36, 13, 36, 15 ],
|
||||
"name" : "baz"
|
||||
}
|
||||
},
|
||||
"args" : [ {
|
||||
"kind" : "ListExpr",
|
||||
"location" : [ 36, 17, 36, 21 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ListValueType",
|
||||
"elementType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "int"
|
||||
}
|
||||
},
|
||||
"elements" : [ {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 36, 18, 36, 18 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "int"
|
||||
},
|
||||
"value" : 1
|
||||
}, {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 36, 20, 36, 20 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "int"
|
||||
},
|
||||
"value" : 2
|
||||
} ]
|
||||
} ]
|
||||
} ]
|
||||
}
|
||||
} ],
|
||||
"errors" : {
|
||||
"errors" : [ ],
|
||||
"kind" : "Errors",
|
||||
"location" : [ 0, 0, 0, 0 ]
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
x:int = 0
|
||||
y:int = 0
|
||||
z:bool = False
|
||||
|
||||
x = z = 1 # Only one error here (assignment to `x = 1` should succeed)
|
||||
x = y = None
|
||||
x = y = []
|
||||
x = a = None
|
||||
x = a = []
|
||||
x = y = True
|
||||
|
@ -0,0 +1,177 @@
|
||||
{
|
||||
"kind" : "Program",
|
||||
"location" : [ 1, 1, 10, 13 ],
|
||||
"declarations" : [ {
|
||||
"kind" : "VarDef",
|
||||
"location" : [ 1, 1, 1, 9 ],
|
||||
"var" : {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 1, 1, 1, 5 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 1, 1, 1, 1 ],
|
||||
"name" : "x"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 1, 3, 1, 5 ],
|
||||
"className" : "int"
|
||||
}
|
||||
},
|
||||
"value" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 1, 9, 1, 9 ],
|
||||
"value" : 0
|
||||
}
|
||||
}, {
|
||||
"kind" : "VarDef",
|
||||
"location" : [ 2, 1, 2, 9 ],
|
||||
"var" : {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 2, 1, 2, 5 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 2, 1, 2, 1 ],
|
||||
"name" : "y"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 2, 3, 2, 5 ],
|
||||
"className" : "int"
|
||||
}
|
||||
},
|
||||
"value" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 2, 9, 2, 9 ],
|
||||
"value" : 0
|
||||
}
|
||||
}, {
|
||||
"kind" : "VarDef",
|
||||
"location" : [ 3, 1, 3, 14 ],
|
||||
"var" : {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 3, 1, 3, 6 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 3, 1, 3, 1 ],
|
||||
"name" : "z"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 3, 3, 3, 6 ],
|
||||
"className" : "bool"
|
||||
}
|
||||
},
|
||||
"value" : {
|
||||
"kind" : "BooleanLiteral",
|
||||
"location" : [ 3, 10, 3, 14 ],
|
||||
"value" : false
|
||||
}
|
||||
} ],
|
||||
"statements" : [ {
|
||||
"kind" : "AssignStmt",
|
||||
"location" : [ 5, 1, 5, 9 ],
|
||||
"targets" : [ {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 5, 1, 5, 1 ],
|
||||
"name" : "x"
|
||||
}, {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 5, 5, 5, 5 ],
|
||||
"name" : "z"
|
||||
} ],
|
||||
"value" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 5, 9, 5, 9 ],
|
||||
"value" : 1
|
||||
}
|
||||
}, {
|
||||
"kind" : "AssignStmt",
|
||||
"location" : [ 6, 1, 6, 12 ],
|
||||
"targets" : [ {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 6, 1, 6, 1 ],
|
||||
"name" : "x"
|
||||
}, {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 6, 5, 6, 5 ],
|
||||
"name" : "y"
|
||||
} ],
|
||||
"value" : {
|
||||
"kind" : "NoneLiteral",
|
||||
"location" : [ 6, 9, 6, 12 ]
|
||||
}
|
||||
}, {
|
||||
"kind" : "AssignStmt",
|
||||
"location" : [ 7, 1, 7, 10 ],
|
||||
"targets" : [ {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 7, 1, 7, 1 ],
|
||||
"name" : "x"
|
||||
}, {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 7, 5, 7, 5 ],
|
||||
"name" : "y"
|
||||
} ],
|
||||
"value" : {
|
||||
"kind" : "ListExpr",
|
||||
"location" : [ 7, 9, 7, 10 ],
|
||||
"elements" : [ ]
|
||||
}
|
||||
}, {
|
||||
"kind" : "AssignStmt",
|
||||
"location" : [ 8, 1, 8, 12 ],
|
||||
"targets" : [ {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 8, 1, 8, 1 ],
|
||||
"name" : "x"
|
||||
}, {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 8, 5, 8, 5 ],
|
||||
"name" : "a"
|
||||
} ],
|
||||
"value" : {
|
||||
"kind" : "NoneLiteral",
|
||||
"location" : [ 8, 9, 8, 12 ]
|
||||
}
|
||||
}, {
|
||||
"kind" : "AssignStmt",
|
||||
"location" : [ 9, 1, 9, 10 ],
|
||||
"targets" : [ {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 9, 1, 9, 1 ],
|
||||
"name" : "x"
|
||||
}, {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 9, 5, 9, 5 ],
|
||||
"name" : "a"
|
||||
} ],
|
||||
"value" : {
|
||||
"kind" : "ListExpr",
|
||||
"location" : [ 9, 9, 9, 10 ],
|
||||
"elements" : [ ]
|
||||
}
|
||||
}, {
|
||||
"kind" : "AssignStmt",
|
||||
"location" : [ 10, 1, 10, 12 ],
|
||||
"targets" : [ {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 10, 1, 10, 1 ],
|
||||
"name" : "x"
|
||||
}, {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 10, 5, 10, 5 ],
|
||||
"name" : "y"
|
||||
} ],
|
||||
"value" : {
|
||||
"kind" : "BooleanLiteral",
|
||||
"location" : [ 10, 9, 10, 12 ],
|
||||
"value" : true
|
||||
}
|
||||
} ],
|
||||
"errors" : {
|
||||
"errors" : [ ],
|
||||
"kind" : "Errors",
|
||||
"location" : [ 0, 0, 0, 0 ]
|
||||
}
|
||||
}
|
@ -0,0 +1,301 @@
|
||||
{
|
||||
"kind" : "Program",
|
||||
"location" : [ 1, 1, 10, 13 ],
|
||||
"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" : 0
|
||||
}
|
||||
}, {
|
||||
"kind" : "VarDef",
|
||||
"location" : [ 2, 1, 2, 9 ],
|
||||
"var" : {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 2, 1, 2, 5 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 2, 1, 2, 1 ],
|
||||
"name" : "y"
|
||||
},
|
||||
"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
|
||||
}
|
||||
}, {
|
||||
"kind" : "VarDef",
|
||||
"location" : [ 3, 1, 3, 14 ],
|
||||
"var" : {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 3, 1, 3, 6 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 3, 1, 3, 1 ],
|
||||
"name" : "z"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 3, 3, 3, 6 ],
|
||||
"className" : "bool"
|
||||
}
|
||||
},
|
||||
"value" : {
|
||||
"kind" : "BooleanLiteral",
|
||||
"location" : [ 3, 10, 3, 14 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "bool"
|
||||
},
|
||||
"value" : false
|
||||
}
|
||||
} ],
|
||||
"statements" : [ {
|
||||
"kind" : "AssignStmt",
|
||||
"location" : [ 5, 1, 5, 9 ],
|
||||
"errorMsg" : "Expected type `bool`; got type `int`",
|
||||
"targets" : [ {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 5, 1, 5, 1 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "int"
|
||||
},
|
||||
"name" : "x"
|
||||
}, {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 5, 5, 5, 5 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "bool"
|
||||
},
|
||||
"name" : "z"
|
||||
} ],
|
||||
"value" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 5, 9, 5, 9 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "int"
|
||||
},
|
||||
"value" : 1
|
||||
}
|
||||
}, {
|
||||
"kind" : "AssignStmt",
|
||||
"location" : [ 6, 1, 6, 12 ],
|
||||
"errorMsg" : "Expected type `int`; got type `<None>`",
|
||||
"targets" : [ {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 6, 1, 6, 1 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "int"
|
||||
},
|
||||
"name" : "x"
|
||||
}, {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 6, 5, 6, 5 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "int"
|
||||
},
|
||||
"name" : "y"
|
||||
} ],
|
||||
"value" : {
|
||||
"kind" : "NoneLiteral",
|
||||
"location" : [ 6, 9, 6, 12 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "<None>"
|
||||
}
|
||||
}
|
||||
}, {
|
||||
"kind" : "AssignStmt",
|
||||
"location" : [ 7, 1, 7, 10 ],
|
||||
"errorMsg" : "Expected type `int`; got type `<Empty>`",
|
||||
"targets" : [ {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 7, 1, 7, 1 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "int"
|
||||
},
|
||||
"name" : "x"
|
||||
}, {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 7, 5, 7, 5 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "int"
|
||||
},
|
||||
"name" : "y"
|
||||
} ],
|
||||
"value" : {
|
||||
"kind" : "ListExpr",
|
||||
"location" : [ 7, 9, 7, 10 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "<Empty>"
|
||||
},
|
||||
"elements" : [ ]
|
||||
}
|
||||
}, {
|
||||
"kind" : "AssignStmt",
|
||||
"location" : [ 8, 1, 8, 12 ],
|
||||
"errorMsg" : "Expected type `int`; got type `<None>`",
|
||||
"targets" : [ {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 8, 1, 8, 1 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "int"
|
||||
},
|
||||
"name" : "x"
|
||||
}, {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 8, 5, 8, 5 ],
|
||||
"errorMsg" : "Not a variable: a",
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "object"
|
||||
},
|
||||
"name" : "a"
|
||||
} ],
|
||||
"value" : {
|
||||
"kind" : "NoneLiteral",
|
||||
"location" : [ 8, 9, 8, 12 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "<None>"
|
||||
}
|
||||
}
|
||||
}, {
|
||||
"kind" : "AssignStmt",
|
||||
"location" : [ 9, 1, 9, 10 ],
|
||||
"errorMsg" : "Expected type `int`; got type `<Empty>`",
|
||||
"targets" : [ {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 9, 1, 9, 1 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "int"
|
||||
},
|
||||
"name" : "x"
|
||||
}, {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 9, 5, 9, 5 ],
|
||||
"errorMsg" : "Not a variable: a",
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "object"
|
||||
},
|
||||
"name" : "a"
|
||||
} ],
|
||||
"value" : {
|
||||
"kind" : "ListExpr",
|
||||
"location" : [ 9, 9, 9, 10 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "<Empty>"
|
||||
},
|
||||
"elements" : [ ]
|
||||
}
|
||||
}, {
|
||||
"kind" : "AssignStmt",
|
||||
"location" : [ 10, 1, 10, 12 ],
|
||||
"errorMsg" : "Expected type `int`; got type `bool`",
|
||||
"targets" : [ {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 10, 1, 10, 1 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "int"
|
||||
},
|
||||
"name" : "x"
|
||||
}, {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 10, 5, 10, 5 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "int"
|
||||
},
|
||||
"name" : "y"
|
||||
} ],
|
||||
"value" : {
|
||||
"kind" : "BooleanLiteral",
|
||||
"location" : [ 10, 9, 10, 12 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "bool"
|
||||
},
|
||||
"value" : true
|
||||
}
|
||||
} ],
|
||||
"errors" : {
|
||||
"errors" : [ {
|
||||
"kind" : "CompilerError",
|
||||
"location" : [ 5, 1, 5, 9 ],
|
||||
"message" : "Expected type `bool`; got type `int`"
|
||||
}, {
|
||||
"kind" : "CompilerError",
|
||||
"location" : [ 6, 1, 6, 12 ],
|
||||
"message" : "Expected type `int`; got type `<None>`"
|
||||
}, {
|
||||
"kind" : "CompilerError",
|
||||
"location" : [ 7, 1, 7, 10 ],
|
||||
"message" : "Expected type `int`; got type `<Empty>`"
|
||||
}, {
|
||||
"kind" : "CompilerError",
|
||||
"location" : [ 8, 1, 8, 12 ],
|
||||
"message" : "Expected type `int`; got type `<None>`"
|
||||
}, {
|
||||
"kind" : "CompilerError",
|
||||
"location" : [ 8, 5, 8, 5 ],
|
||||
"message" : "Not a variable: a"
|
||||
}, {
|
||||
"kind" : "CompilerError",
|
||||
"location" : [ 9, 1, 9, 10 ],
|
||||
"message" : "Expected type `int`; got type `<Empty>`"
|
||||
}, {
|
||||
"kind" : "CompilerError",
|
||||
"location" : [ 9, 5, 9, 5 ],
|
||||
"message" : "Not a variable: a"
|
||||
}, {
|
||||
"kind" : "CompilerError",
|
||||
"location" : [ 10, 1, 10, 12 ],
|
||||
"message" : "Expected type `int`; got type `bool`"
|
||||
} ],
|
||||
"kind" : "Errors",
|
||||
"location" : [ 0, 0, 0, 0 ]
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
class A(object):
|
||||
x:int = 1
|
||||
|
||||
def foo(self:"A") -> int:
|
||||
return 0
|
||||
|
||||
class B(A):
|
||||
x:int = 2 # Bad
|
||||
foo:str = "" # Bad
|
||||
|
||||
A()
|
||||
|
||||
|
@ -0,0 +1,155 @@
|
||||
{
|
||||
"kind" : "Program",
|
||||
"location" : [ 1, 1, 11, 4 ],
|
||||
"declarations" : [ {
|
||||
"kind" : "ClassDef",
|
||||
"location" : [ 1, 1, 7, 0 ],
|
||||
"name" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 1, 7, 1, 7 ],
|
||||
"name" : "A"
|
||||
},
|
||||
"superClass" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 1, 9, 1, 14 ],
|
||||
"name" : "object"
|
||||
},
|
||||
"declarations" : [ {
|
||||
"kind" : "VarDef",
|
||||
"location" : [ 2, 5, 2, 13 ],
|
||||
"var" : {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 2, 5, 2, 9 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 2, 5, 2, 5 ],
|
||||
"name" : "x"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 2, 7, 2, 9 ],
|
||||
"className" : "int"
|
||||
}
|
||||
},
|
||||
"value" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 2, 13, 2, 13 ],
|
||||
"value" : 1
|
||||
}
|
||||
}, {
|
||||
"kind" : "FuncDef",
|
||||
"location" : [ 4, 5, 5, 17 ],
|
||||
"name" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 4, 9, 4, 11 ],
|
||||
"name" : "foo"
|
||||
},
|
||||
"params" : [ {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 4, 13, 4, 20 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 4, 13, 4, 16 ],
|
||||
"name" : "self"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 4, 18, 4, 20 ],
|
||||
"className" : "A"
|
||||
}
|
||||
} ],
|
||||
"returnType" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 4, 26, 4, 28 ],
|
||||
"className" : "int"
|
||||
},
|
||||
"declarations" : [ ],
|
||||
"statements" : [ {
|
||||
"kind" : "ReturnStmt",
|
||||
"location" : [ 5, 9, 5, 16 ],
|
||||
"value" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 5, 16, 5, 16 ],
|
||||
"value" : 0
|
||||
}
|
||||
} ]
|
||||
} ]
|
||||
}, {
|
||||
"kind" : "ClassDef",
|
||||
"location" : [ 7, 1, 9, 23 ],
|
||||
"name" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 7, 7, 7, 7 ],
|
||||
"name" : "B"
|
||||
},
|
||||
"superClass" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 7, 9, 7, 9 ],
|
||||
"name" : "A"
|
||||
},
|
||||
"declarations" : [ {
|
||||
"kind" : "VarDef",
|
||||
"location" : [ 8, 5, 8, 13 ],
|
||||
"var" : {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 8, 5, 8, 9 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 8, 5, 8, 5 ],
|
||||
"name" : "x"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 8, 7, 8, 9 ],
|
||||
"className" : "int"
|
||||
}
|
||||
},
|
||||
"value" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 8, 13, 8, 13 ],
|
||||
"value" : 2
|
||||
}
|
||||
}, {
|
||||
"kind" : "VarDef",
|
||||
"location" : [ 9, 5, 9, 16 ],
|
||||
"var" : {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 9, 5, 9, 11 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 9, 5, 9, 7 ],
|
||||
"name" : "foo"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 9, 9, 9, 11 ],
|
||||
"className" : "str"
|
||||
}
|
||||
},
|
||||
"value" : {
|
||||
"kind" : "StringLiteral",
|
||||
"location" : [ 9, 15, 9, 16 ],
|
||||
"value" : ""
|
||||
}
|
||||
} ]
|
||||
} ],
|
||||
"statements" : [ {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 11, 1, 11, 3 ],
|
||||
"expr" : {
|
||||
"kind" : "CallExpr",
|
||||
"location" : [ 11, 1, 11, 3 ],
|
||||
"function" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 11, 1, 11, 1 ],
|
||||
"name" : "A"
|
||||
},
|
||||
"args" : [ ]
|
||||
}
|
||||
} ],
|
||||
"errors" : {
|
||||
"errors" : [ ],
|
||||
"kind" : "Errors",
|
||||
"location" : [ 0, 0, 0, 0 ]
|
||||
}
|
||||
}
|
@ -0,0 +1,165 @@
|
||||
{
|
||||
"kind" : "Program",
|
||||
"location" : [ 1, 1, 11, 4 ],
|
||||
"declarations" : [ {
|
||||
"kind" : "ClassDef",
|
||||
"location" : [ 1, 1, 7, 0 ],
|
||||
"name" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 1, 7, 1, 7 ],
|
||||
"name" : "A"
|
||||
},
|
||||
"superClass" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 1, 9, 1, 14 ],
|
||||
"name" : "object"
|
||||
},
|
||||
"declarations" : [ {
|
||||
"kind" : "VarDef",
|
||||
"location" : [ 2, 5, 2, 13 ],
|
||||
"var" : {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 2, 5, 2, 9 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 2, 5, 2, 5 ],
|
||||
"name" : "x"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 2, 7, 2, 9 ],
|
||||
"className" : "int"
|
||||
}
|
||||
},
|
||||
"value" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 2, 13, 2, 13 ],
|
||||
"value" : 1
|
||||
}
|
||||
}, {
|
||||
"kind" : "FuncDef",
|
||||
"location" : [ 4, 5, 5, 17 ],
|
||||
"name" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 4, 9, 4, 11 ],
|
||||
"name" : "foo"
|
||||
},
|
||||
"params" : [ {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 4, 13, 4, 20 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 4, 13, 4, 16 ],
|
||||
"name" : "self"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 4, 18, 4, 20 ],
|
||||
"className" : "A"
|
||||
}
|
||||
} ],
|
||||
"returnType" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 4, 26, 4, 28 ],
|
||||
"className" : "int"
|
||||
},
|
||||
"declarations" : [ ],
|
||||
"statements" : [ {
|
||||
"kind" : "ReturnStmt",
|
||||
"location" : [ 5, 9, 5, 16 ],
|
||||
"value" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 5, 16, 5, 16 ],
|
||||
"value" : 0
|
||||
}
|
||||
} ]
|
||||
} ]
|
||||
}, {
|
||||
"kind" : "ClassDef",
|
||||
"location" : [ 7, 1, 9, 23 ],
|
||||
"name" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 7, 7, 7, 7 ],
|
||||
"name" : "B"
|
||||
},
|
||||
"superClass" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 7, 9, 7, 9 ],
|
||||
"name" : "A"
|
||||
},
|
||||
"declarations" : [ {
|
||||
"kind" : "VarDef",
|
||||
"location" : [ 8, 5, 8, 13 ],
|
||||
"var" : {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 8, 5, 8, 9 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 8, 5, 8, 5 ],
|
||||
"errorMsg" : "Cannot re-define attribute: x",
|
||||
"name" : "x"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 8, 7, 8, 9 ],
|
||||
"className" : "int"
|
||||
}
|
||||
},
|
||||
"value" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 8, 13, 8, 13 ],
|
||||
"value" : 2
|
||||
}
|
||||
}, {
|
||||
"kind" : "VarDef",
|
||||
"location" : [ 9, 5, 9, 16 ],
|
||||
"var" : {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 9, 5, 9, 11 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 9, 5, 9, 7 ],
|
||||
"errorMsg" : "Cannot re-define attribute: foo",
|
||||
"name" : "foo"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 9, 9, 9, 11 ],
|
||||
"className" : "str"
|
||||
}
|
||||
},
|
||||
"value" : {
|
||||
"kind" : "StringLiteral",
|
||||
"location" : [ 9, 15, 9, 16 ],
|
||||
"value" : ""
|
||||
}
|
||||
} ]
|
||||
} ],
|
||||
"statements" : [ {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 11, 1, 11, 3 ],
|
||||
"expr" : {
|
||||
"kind" : "CallExpr",
|
||||
"location" : [ 11, 1, 11, 3 ],
|
||||
"function" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 11, 1, 11, 1 ],
|
||||
"name" : "A"
|
||||
},
|
||||
"args" : [ ]
|
||||
}
|
||||
} ],
|
||||
"errors" : {
|
||||
"errors" : [ {
|
||||
"kind" : "CompilerError",
|
||||
"location" : [ 8, 5, 8, 5 ],
|
||||
"message" : "Cannot re-define attribute: x"
|
||||
}, {
|
||||
"kind" : "CompilerError",
|
||||
"location" : [ 9, 5, 9, 7 ],
|
||||
"message" : "Cannot re-define attribute: foo"
|
||||
} ],
|
||||
"kind" : "Errors",
|
||||
"location" : [ 0, 0, 0, 0 ]
|
||||
}
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
class A(object):
|
||||
x:int = True
|
||||
|
||||
A()
|
@ -0,0 +1,60 @@
|
||||
{
|
||||
"kind" : "Program",
|
||||
"location" : [ 1, 1, 4, 4 ],
|
||||
"declarations" : [ {
|
||||
"kind" : "ClassDef",
|
||||
"location" : [ 1, 1, 2, 17 ],
|
||||
"name" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 1, 7, 1, 7 ],
|
||||
"name" : "A"
|
||||
},
|
||||
"superClass" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 1, 9, 1, 14 ],
|
||||
"name" : "object"
|
||||
},
|
||||
"declarations" : [ {
|
||||
"kind" : "VarDef",
|
||||
"location" : [ 2, 5, 2, 16 ],
|
||||
"var" : {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 2, 5, 2, 9 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 2, 5, 2, 5 ],
|
||||
"name" : "x"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 2, 7, 2, 9 ],
|
||||
"className" : "int"
|
||||
}
|
||||
},
|
||||
"value" : {
|
||||
"kind" : "BooleanLiteral",
|
||||
"location" : [ 2, 13, 2, 16 ],
|
||||
"value" : true
|
||||
}
|
||||
} ]
|
||||
} ],
|
||||
"statements" : [ {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 4, 1, 4, 3 ],
|
||||
"expr" : {
|
||||
"kind" : "CallExpr",
|
||||
"location" : [ 4, 1, 4, 3 ],
|
||||
"function" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 4, 1, 4, 1 ],
|
||||
"name" : "A"
|
||||
},
|
||||
"args" : [ ]
|
||||
}
|
||||
} ],
|
||||
"errors" : {
|
||||
"errors" : [ ],
|
||||
"kind" : "Errors",
|
||||
"location" : [ 0, 0, 0, 0 ]
|
||||
}
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
{
|
||||
"kind" : "Program",
|
||||
"location" : [ 1, 1, 4, 4 ],
|
||||
"declarations" : [ {
|
||||
"kind" : "ClassDef",
|
||||
"location" : [ 1, 1, 2, 17 ],
|
||||
"name" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 1, 7, 1, 7 ],
|
||||
"name" : "A"
|
||||
},
|
||||
"superClass" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 1, 9, 1, 14 ],
|
||||
"name" : "object"
|
||||
},
|
||||
"declarations" : [ {
|
||||
"kind" : "VarDef",
|
||||
"location" : [ 2, 5, 2, 16 ],
|
||||
"errorMsg" : "Expected type `int`; got type `bool`",
|
||||
"var" : {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 2, 5, 2, 9 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 2, 5, 2, 5 ],
|
||||
"name" : "x"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 2, 7, 2, 9 ],
|
||||
"className" : "int"
|
||||
}
|
||||
},
|
||||
"value" : {
|
||||
"kind" : "BooleanLiteral",
|
||||
"location" : [ 2, 13, 2, 16 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "bool"
|
||||
},
|
||||
"value" : true
|
||||
}
|
||||
} ]
|
||||
} ],
|
||||
"statements" : [ {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 4, 1, 4, 3 ],
|
||||
"expr" : {
|
||||
"kind" : "CallExpr",
|
||||
"location" : [ 4, 1, 4, 3 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "A"
|
||||
},
|
||||
"function" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 4, 1, 4, 1 ],
|
||||
"name" : "A"
|
||||
},
|
||||
"args" : [ ]
|
||||
}
|
||||
} ],
|
||||
"errors" : {
|
||||
"errors" : [ {
|
||||
"kind" : "CompilerError",
|
||||
"location" : [ 2, 5, 2, 16 ],
|
||||
"message" : "Expected type `int`; got type `bool`"
|
||||
} ],
|
||||
"kind" : "Errors",
|
||||
"location" : [ 0, 0, 0, 0 ]
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
class A(object):
|
||||
x:int = 1
|
||||
|
||||
def __init__(self:"A", x:int): # Bad override
|
||||
pass
|
||||
|
||||
A(1)
|
||||
|
@ -0,0 +1,106 @@
|
||||
{
|
||||
"kind" : "Program",
|
||||
"location" : [ 1, 1, 7, 5 ],
|
||||
"declarations" : [ {
|
||||
"kind" : "ClassDef",
|
||||
"location" : [ 1, 1, 7, 0 ],
|
||||
"name" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 1, 7, 1, 7 ],
|
||||
"name" : "A"
|
||||
},
|
||||
"superClass" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 1, 9, 1, 14 ],
|
||||
"name" : "object"
|
||||
},
|
||||
"declarations" : [ {
|
||||
"kind" : "VarDef",
|
||||
"location" : [ 2, 5, 2, 13 ],
|
||||
"var" : {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 2, 5, 2, 9 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 2, 5, 2, 5 ],
|
||||
"name" : "x"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 2, 7, 2, 9 ],
|
||||
"className" : "int"
|
||||
}
|
||||
},
|
||||
"value" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 2, 13, 2, 13 ],
|
||||
"value" : 1
|
||||
}
|
||||
}, {
|
||||
"kind" : "FuncDef",
|
||||
"location" : [ 4, 5, 5, 13 ],
|
||||
"name" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 4, 9, 4, 16 ],
|
||||
"name" : "__init__"
|
||||
},
|
||||
"params" : [ {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 4, 18, 4, 25 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 4, 18, 4, 21 ],
|
||||
"name" : "self"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 4, 23, 4, 25 ],
|
||||
"className" : "A"
|
||||
}
|
||||
}, {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 4, 28, 4, 32 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 4, 28, 4, 28 ],
|
||||
"name" : "x"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 4, 30, 4, 32 ],
|
||||
"className" : "int"
|
||||
}
|
||||
} ],
|
||||
"returnType" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 4, 34, 4, 34 ],
|
||||
"className" : "<None>"
|
||||
},
|
||||
"declarations" : [ ],
|
||||
"statements" : [ ]
|
||||
} ]
|
||||
} ],
|
||||
"statements" : [ {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 7, 1, 7, 4 ],
|
||||
"expr" : {
|
||||
"kind" : "CallExpr",
|
||||
"location" : [ 7, 1, 7, 4 ],
|
||||
"function" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 7, 1, 7, 1 ],
|
||||
"name" : "A"
|
||||
},
|
||||
"args" : [ {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 7, 3, 7, 3 ],
|
||||
"value" : 1
|
||||
} ]
|
||||
}
|
||||
} ],
|
||||
"errors" : {
|
||||
"errors" : [ ],
|
||||
"kind" : "Errors",
|
||||
"location" : [ 0, 0, 0, 0 ]
|
||||
}
|
||||
}
|
@ -0,0 +1,111 @@
|
||||
{
|
||||
"kind" : "Program",
|
||||
"location" : [ 1, 1, 7, 5 ],
|
||||
"declarations" : [ {
|
||||
"kind" : "ClassDef",
|
||||
"location" : [ 1, 1, 7, 0 ],
|
||||
"name" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 1, 7, 1, 7 ],
|
||||
"name" : "A"
|
||||
},
|
||||
"superClass" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 1, 9, 1, 14 ],
|
||||
"name" : "object"
|
||||
},
|
||||
"declarations" : [ {
|
||||
"kind" : "VarDef",
|
||||
"location" : [ 2, 5, 2, 13 ],
|
||||
"var" : {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 2, 5, 2, 9 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 2, 5, 2, 5 ],
|
||||
"name" : "x"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 2, 7, 2, 9 ],
|
||||
"className" : "int"
|
||||
}
|
||||
},
|
||||
"value" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 2, 13, 2, 13 ],
|
||||
"value" : 1
|
||||
}
|
||||
}, {
|
||||
"kind" : "FuncDef",
|
||||
"location" : [ 4, 5, 5, 13 ],
|
||||
"name" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 4, 9, 4, 16 ],
|
||||
"errorMsg" : "Method overridden with different type signature: __init__",
|
||||
"name" : "__init__"
|
||||
},
|
||||
"params" : [ {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 4, 18, 4, 25 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 4, 18, 4, 21 ],
|
||||
"name" : "self"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 4, 23, 4, 25 ],
|
||||
"className" : "A"
|
||||
}
|
||||
}, {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 4, 28, 4, 32 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 4, 28, 4, 28 ],
|
||||
"name" : "x"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 4, 30, 4, 32 ],
|
||||
"className" : "int"
|
||||
}
|
||||
} ],
|
||||
"returnType" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 4, 34, 4, 34 ],
|
||||
"className" : "<None>"
|
||||
},
|
||||
"declarations" : [ ],
|
||||
"statements" : [ ]
|
||||
} ]
|
||||
} ],
|
||||
"statements" : [ {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 7, 1, 7, 4 ],
|
||||
"expr" : {
|
||||
"kind" : "CallExpr",
|
||||
"location" : [ 7, 1, 7, 4 ],
|
||||
"function" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 7, 1, 7, 1 ],
|
||||
"name" : "A"
|
||||
},
|
||||
"args" : [ {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 7, 3, 7, 3 ],
|
||||
"value" : 1
|
||||
} ]
|
||||
}
|
||||
} ],
|
||||
"errors" : {
|
||||
"errors" : [ {
|
||||
"kind" : "CompilerError",
|
||||
"location" : [ 4, 9, 4, 16 ],
|
||||
"message" : "Method overridden with different type signature: __init__"
|
||||
} ],
|
||||
"kind" : "Errors",
|
||||
"location" : [ 0, 0, 0, 0 ]
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
class A(object):
|
||||
def __init__(self:"A"):
|
||||
return 1 # Bad
|
||||
|
||||
A()
|
@ -0,0 +1,75 @@
|
||||
{
|
||||
"kind" : "Program",
|
||||
"location" : [ 1, 1, 5, 4 ],
|
||||
"declarations" : [ {
|
||||
"kind" : "ClassDef",
|
||||
"location" : [ 1, 1, 5, 0 ],
|
||||
"name" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 1, 7, 1, 7 ],
|
||||
"name" : "A"
|
||||
},
|
||||
"superClass" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 1, 9, 1, 14 ],
|
||||
"name" : "object"
|
||||
},
|
||||
"declarations" : [ {
|
||||
"kind" : "FuncDef",
|
||||
"location" : [ 2, 5, 3, 23 ],
|
||||
"name" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 2, 9, 2, 16 ],
|
||||
"name" : "__init__"
|
||||
},
|
||||
"params" : [ {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 2, 18, 2, 25 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 2, 18, 2, 21 ],
|
||||
"name" : "self"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 2, 23, 2, 25 ],
|
||||
"className" : "A"
|
||||
}
|
||||
} ],
|
||||
"returnType" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 2, 27, 2, 27 ],
|
||||
"className" : "<None>"
|
||||
},
|
||||
"declarations" : [ ],
|
||||
"statements" : [ {
|
||||
"kind" : "ReturnStmt",
|
||||
"location" : [ 3, 9, 3, 16 ],
|
||||
"value" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 3, 16, 3, 16 ],
|
||||
"value" : 1
|
||||
}
|
||||
} ]
|
||||
} ]
|
||||
} ],
|
||||
"statements" : [ {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 5, 1, 5, 3 ],
|
||||
"expr" : {
|
||||
"kind" : "CallExpr",
|
||||
"location" : [ 5, 1, 5, 3 ],
|
||||
"function" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 5, 1, 5, 1 ],
|
||||
"name" : "A"
|
||||
},
|
||||
"args" : [ ]
|
||||
}
|
||||
} ],
|
||||
"errors" : {
|
||||
"errors" : [ ],
|
||||
"kind" : "Errors",
|
||||
"location" : [ 0, 0, 0, 0 ]
|
||||
}
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
{
|
||||
"kind" : "Program",
|
||||
"location" : [ 1, 1, 5, 4 ],
|
||||
"declarations" : [ {
|
||||
"kind" : "ClassDef",
|
||||
"location" : [ 1, 1, 5, 0 ],
|
||||
"name" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 1, 7, 1, 7 ],
|
||||
"name" : "A"
|
||||
},
|
||||
"superClass" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 1, 9, 1, 14 ],
|
||||
"name" : "object"
|
||||
},
|
||||
"declarations" : [ {
|
||||
"kind" : "FuncDef",
|
||||
"location" : [ 2, 5, 3, 23 ],
|
||||
"name" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 2, 9, 2, 16 ],
|
||||
"name" : "__init__"
|
||||
},
|
||||
"params" : [ {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 2, 18, 2, 25 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 2, 18, 2, 21 ],
|
||||
"name" : "self"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 2, 23, 2, 25 ],
|
||||
"className" : "A"
|
||||
}
|
||||
} ],
|
||||
"returnType" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 2, 27, 2, 27 ],
|
||||
"className" : "<None>"
|
||||
},
|
||||
"declarations" : [ ],
|
||||
"statements" : [ {
|
||||
"kind" : "ReturnStmt",
|
||||
"location" : [ 3, 9, 3, 16 ],
|
||||
"errorMsg" : "Expected type `<None>`; got type `int`",
|
||||
"value" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 3, 16, 3, 16 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "int"
|
||||
},
|
||||
"value" : 1
|
||||
}
|
||||
} ]
|
||||
} ]
|
||||
} ],
|
||||
"statements" : [ {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 5, 1, 5, 3 ],
|
||||
"expr" : {
|
||||
"kind" : "CallExpr",
|
||||
"location" : [ 5, 1, 5, 3 ],
|
||||
"inferredType" : {
|
||||
"kind" : "ClassValueType",
|
||||
"className" : "A"
|
||||
},
|
||||
"function" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 5, 1, 5, 1 ],
|
||||
"name" : "A"
|
||||
},
|
||||
"args" : [ ]
|
||||
}
|
||||
} ],
|
||||
"errors" : {
|
||||
"errors" : [ {
|
||||
"kind" : "CompilerError",
|
||||
"location" : [ 3, 9, 3, 16 ],
|
||||
"message" : "Expected type `<None>`; got type `int`"
|
||||
} ],
|
||||
"kind" : "Errors",
|
||||
"location" : [ 0, 0, 0, 0 ]
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
x:int = 0
|
||||
o:object = None
|
||||
|
||||
x.foo
|
||||
o.bar
|
||||
o.baz = 1
|
@ -0,0 +1,110 @@
|
||||
{
|
||||
"kind" : "Program",
|
||||
"location" : [ 1, 1, 6, 10 ],
|
||||
"declarations" : [ {
|
||||
"kind" : "VarDef",
|
||||
"location" : [ 1, 1, 1, 9 ],
|
||||
"var" : {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 1, 1, 1, 5 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 1, 1, 1, 1 ],
|
||||
"name" : "x"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 1, 3, 1, 5 ],
|
||||
"className" : "int"
|
||||
}
|
||||
},
|
||||
"value" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 1, 9, 1, 9 ],
|
||||
"value" : 0
|
||||
}
|
||||
}, {
|
||||
"kind" : "VarDef",
|
||||
"location" : [ 2, 1, 2, 15 ],
|
||||
"var" : {
|
||||
"kind" : "TypedVar",
|
||||
"location" : [ 2, 1, 2, 8 ],
|
||||
"identifier" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 2, 1, 2, 1 ],
|
||||
"name" : "o"
|
||||
},
|
||||
"type" : {
|
||||
"kind" : "ClassType",
|
||||
"location" : [ 2, 3, 2, 8 ],
|
||||
"className" : "object"
|
||||
}
|
||||
},
|
||||
"value" : {
|
||||
"kind" : "NoneLiteral",
|
||||
"location" : [ 2, 12, 2, 15 ]
|
||||
}
|
||||
} ],
|
||||
"statements" : [ {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 4, 1, 4, 5 ],
|
||||
"expr" : {
|
||||
"kind" : "MemberExpr",
|
||||
"location" : [ 4, 1, 4, 5 ],
|
||||
"object" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 4, 1, 4, 1 ],
|
||||
"name" : "x"
|
||||
},
|
||||
"member" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 4, 3, 4, 5 ],
|
||||
"name" : "foo"
|
||||
}
|
||||
}
|
||||
}, {
|
||||
"kind" : "ExprStmt",
|
||||
"location" : [ 5, 1, 5, 5 ],
|
||||
"expr" : {
|
||||
"kind" : "MemberExpr",
|
||||
"location" : [ 5, 1, 5, 5 ],
|
||||
"object" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 5, 1, 5, 1 ],
|
||||
"name" : "o"
|
||||
},
|
||||
"member" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 5, 3, 5, 5 ],
|
||||
"name" : "bar"
|
||||
}
|
||||
}
|
||||
}, {
|
||||
"kind" : "AssignStmt",
|
||||
"location" : [ 6, 1, 6, 9 ],
|
||||
"targets" : [ {
|
||||
"kind" : "MemberExpr",
|
||||
"location" : [ 6, 1, 6, 5 ],
|
||||
"object" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 6, 1, 6, 1 ],
|
||||
"name" : "o"
|
||||
},
|
||||
"member" : {
|
||||
"kind" : "Identifier",
|
||||
"location" : [ 6, 3, 6, 5 ],
|
||||
"name" : "baz"
|
||||
}
|
||||
} ],
|
||||
"value" : {
|
||||
"kind" : "IntegerLiteral",
|
||||
"location" : [ 6, 9, 6, 9 ],
|
||||
"value" : 1
|
||||
}
|
||||
} ],
|
||||
"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…
Reference in new issue