Implement nearest-loop transfers and reachable binding analysis

This commit is contained in:
Codex committed 2026-11-23 19:41:01 +08:00
1 parent 095eef1370
commit 69c5dc8d20
40 files changed
+953 -110

No files matched your search

@@ -0,0 +1,9 @@
{
"args": {},
"function": "main",
"stdout": "",
"value": {
"decimal": "7",
"type": "int"
}
}
@@ -0,0 +1,13 @@
## @exec main
- `while true`
**结果 = 6**
`break`
`结果 = 未到达`
`end`
`return 结果 + 1`
@@ -0,0 +1,9 @@
{
"args": {},
"function": "main",
"stdout": "",
"value": {
"decimal": "3",
"type": "int"
}
}
@@ -0,0 +1,15 @@
## @exec main
`位置 = 0`
`while 位置 < 3`
`位置 = 位置 + 1`
`continue`
`return 未到达`
`end`
`return 位置`
@@ -0,0 +1,9 @@
{
"args": {},
"function": "main",
"stdout": "",
"value": {
"decimal": "26",
"type": "int"
}
}
@@ -0,0 +1,41 @@
## @exec main
`外 = 0`
`合计 = 0`
`while 外 < 3`
`外 = 外 + 1`
`内 = 0`
`while 内 < 4`
`内 = 内 + 1`
`if 内 == 1`
`continue`
`else if 内 == 3`
`break`
`end`
`合计 = 合计 + 外`
`end`
`if 外 == 2`
`continue`
`end`
`合计 = 合计 + 10`
`end`
`return 合计`
@@ -0,0 +1,9 @@
{
"args": {},
"function": "main",
"stdout": "",
"value": {
"decimal": "42",
"type": "int"
}
}
@@ -0,0 +1,25 @@
## @exec main
The words continue and break in this sentence are ordinary prose.
`while true`
`if false`
`break`
`else if true`
`return 42`
`end`
`continue`
`end`
`return 未到达`
### @knowledge Control vocabulary
`break` and **continue** and *else if* are examples of inert text here.
@@ -0,0 +1,9 @@
{
"args": {},
"function": "main",
"stdout": "",
"value": {
"decimal": "5",
"type": "int"
}
}
@@ -0,0 +1,11 @@
## @exec break
`params(continue: Int)`
`return continue + 1`
## @exec main
`continue = break(4)`
`return continue`
@@ -0,0 +1,5 @@
{
"codes": [
"sem.break_outside_loop"
]
}
@@ -0,0 +1,11 @@
## @exec main
`while true`
`子函数()`
`end`
## @exec 子函数
`break`
@@ -0,0 +1,5 @@
{
"codes": [
"sem.syntax"
]
}
@@ -0,0 +1,7 @@
## @exec main
`while true`
`break 2`
`end`
@@ -0,0 +1,5 @@
{
"codes": [
"sem.break_outside_loop"
]
}
@@ -0,0 +1,7 @@
## @exec main
`if true`
`break`
`end`
@@ -0,0 +1,5 @@
{
"codes": [
"symbol.uninitialized"
]
}
@@ -0,0 +1,19 @@
## @exec main
`params(标志: Bool)`
`while true`
`if 标志`
`break`
`end`
`结果 = 1`
`break`
`end`
`return 结果`
@@ -0,0 +1,5 @@
{
"codes": [
"sem.syntax"
]
}
@@ -0,0 +1,7 @@
## @exec main
`while true`
`continue outer`
`end`
@@ -0,0 +1,5 @@
{
"codes": [
"sem.continue_outside_loop"
]
}
@@ -0,0 +1,3 @@
## @exec main
`continue`
@@ -0,0 +1,5 @@
{
"codes": [
"sem.syntax"
]
}
@@ -0,0 +1,7 @@
## @exec main
`while true`
`break 未知`
`end`
@@ -0,0 +1,7 @@
{
"codes": [
"sem.continue_outside_loop",
"sem.unclosed_control",
"sem.unmatched_end"
]
}
@@ -0,0 +1,9 @@
## @exec main
`while true`
### 子段
`continue`
`end`
@@ -0,0 +1,6 @@
{
"codes": [
"sem.unclosed_control",
"sem.unmatched_end"
]
}
@@ -0,0 +1,11 @@
## @exec main
`while true`
### @knowledge Loop notes
`break` `end`
### @exec Next
`end`