新增 iterpreter.py #1

Merged
Sapiens_homo merged 2 commits from Wuboshit/fnn:main into main 2026-10-28 02:15:03 +00:00
Contributor

皮炎

皮炎
Owner

trace using

{
	"step": [
		{
			"op": "push" | "pop",
			"value": number,
			"stack": "data" | "ctrl"
		}
	]
}

for every step might be better, e.g., for 12 5 DUP + -:

{
	"steps": [
		{
			"step": [
				{
					"op": "push",
					"value": 12,
					"stack": "data"
				}
			]
		},
		{
			"step": [
				{
					"op": "push",
					"value": 5,
					"stack": "data"
				}
			]
		},
		{
			"step": [
				{
					"op": "pop",
					"value": 5,
					"stack": "data"
				},
				{
					"op": "push",
					"value": 5,
					"stack": "data"
				},
				{
					"op": "push",
					"value": 5,
					"stack": "data"
				}
			]
		},
		{
			"step": [
				{
					"op": "pop",
					"value": 5,
					"stack": "data"
				},
				{
					"op": "pop",
					"value": 5,
					"stack": "data"
				},
				{
					"op": "push",
					"value": 10,
					"stack": "data"
				}
			]
		},
		{
			"step": [
				{
					"op": "pop",
					"value": 10,
					"stack": "data"
				},
				{
					"op": "pop",
					"value": 12,
					"stack": "data"
				},
				{
					"op": "push",
					"value": 2,
					"stack": "data"
				}
			]
		}
	]
}
trace using ```json { "step": [ { "op": "push" | "pop", "value": number, "stack": "data" | "ctrl" } ] } ``` for every step might be better, e.g., for `12 5 DUP + -`: ```json { "steps": [ { "step": [ { "op": "push", "value": 12, "stack": "data" } ] }, { "step": [ { "op": "push", "value": 5, "stack": "data" } ] }, { "step": [ { "op": "pop", "value": 5, "stack": "data" }, { "op": "push", "value": 5, "stack": "data" }, { "op": "push", "value": 5, "stack": "data" } ] }, { "step": [ { "op": "pop", "value": 5, "stack": "data" }, { "op": "pop", "value": 5, "stack": "data" }, { "op": "push", "value": 10, "stack": "data" } ] }, { "step": [ { "op": "pop", "value": 10, "stack": "data" }, { "op": "pop", "value": 12, "stack": "data" }, { "op": "push", "value": 2, "stack": "data" } ] } ] } ```
Owner

and, please put the file inside interperter/

and, please put the file inside `interperter/`
Owner

oh, that format might not good enough

{
	"script": [
		"per identifier per item"
	],
	"steps": {
		"step": {
			"d": [ { "op": "push" | "pop", "value": number } ],
			"c": [ { "op": "push" | "pop", "value": number } ]
		}
	}
}

@Wuboshit

oh, that format might not good enough ```json { "script": [ "per identifier per item" ], "steps": { "step": { "d": [ { "op": "push" | "pop", "value": number } ], "c": [ { "op": "push" | "pop", "value": number } ] } } } ``` @Wuboshit
Owner
{
	"script": [
		"12",
		"5",
		"DUP",
		"+",
		"-"
	],
	"steps": [
		{
			"d": [
				{ "op": "push", "value": 12 }
			],
			"c": []
		},
		{
			"d": [
				{ "op": "push", "value": 5 }
			],
			"c": []
		},
		{
			"d": [
				{ "op": "pop", "value": 5 },
				{ "op": "push", "value": 5 },
				{ "op": "push", "value": 5 }
			],
			"c": []
		},
		{
			"d": [
				{ "op": "pop", "value": 5 },
				{ "op": "pop", "value": 5 },
				{ "op": "push", "value": 10 }
			],
			"c": []
		},
		{
			"d": [
				{ "op": "pop", "value": 10 },
				{ "op": "pop", "value": 12 },
				{ "op": "push", "value": 2 }
			],
			"c": []
		}
	]
}
```json { "script": [ "12", "5", "DUP", "+", "-" ], "steps": [ { "d": [ { "op": "push", "value": 12 } ], "c": [] }, { "d": [ { "op": "push", "value": 5 } ], "c": [] }, { "d": [ { "op": "pop", "value": 5 }, { "op": "push", "value": 5 }, { "op": "push", "value": 5 } ], "c": [] }, { "d": [ { "op": "pop", "value": 5 }, { "op": "pop", "value": 5 }, { "op": "push", "value": 10 } ], "c": [] }, { "d": [ { "op": "pop", "value": 10 }, { "op": "pop", "value": 12 }, { "op": "push", "value": 2 } ], "c": [] } ] } ```
Wuboshit changed title from WIP:新增 iterpreter.py to 新增 iterpreter.py 2026-10-28 02:13:29 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Sapiens_homo/fnn!1
No description provided.