From 19e0f3ac424c050de2472d3f5db7b5971d2d01e4 Mon Sep 17 00:00:00 2001 From: gefrus112 <329268472+gefrus112@users.noreply.github.com> Date: Thu, 22 Oct 2026 13:36:47 +0000 Subject: [PATCH] Upgrade language recovery and python.org-style site Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com> --- README.md | 8 +- docs.html | 26 ++- docs/LANGUAGE.md | 57 ++++-- download.html | 7 +- editors/vscode/snippets/pyv2.json | 24 +++ editors/vscode/syntaxes/pyv2.tmLanguage.json | 2 +- examples/error_recovery.pyv2 | 27 +++ games.html | 3 +- guide.html | 27 +-- index.html | 152 +++++++++++---- main.js | 31 ++- playground.html | 4 +- playground.js | 29 ++- pyv2.js | 117 +++++++++++- pyv2/assets/pyv2.js | 117 +++++++++++- pyv2/cli.py | 2 +- pyv2/interpreter.py | 90 +++++++++ pyv2/lexer.py | 4 +- pyv2/parser.py | 41 +++- site.js | 27 +++ style.css | 191 +++++++++++++++++++ tests/test_games_site.py | 23 ++- tests/test_parity.py | 16 ++ tests/test_pyv2.py | 56 ++++++ tutorial.html | 50 +++-- 25 files changed, 1010 insertions(+), 121 deletions(-) create mode 100644 examples/error_recovery.pyv2 diff --git a/README.md b/README.md index 3f47ac0..64e906c 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,8 @@ Python v2 is a programming language that lets you work quickly and integrate systems more effectively — same energy as the original snake, without the paper cuts. No indentation errors. Real closures. F-strings that just work. -A ternary that reads left to right. And it runs **right in your browser**. +Structured errors you can actually recover from. A ternary that reads left to +right. And it runs **right in your browser**. ```python # hello.pyv2 @@ -45,6 +46,7 @@ The product is: 384 | `nonlocal` scavenger hunts | closures just work | | `"n=" + str(n)` | `"n=" + n` | | `x if ok else y` (backwards) | `ok ? x : y` | +| exception classes for routine app errors | `catch error` gives a useful map; `finally` always runs | | `assert` is a keyword with moods | `assert(cond, msg)` is a function | | trailing commas *sometimes* | trailing commas & multi-line everything | | one runtime | two parity-tested runtimes — CLI **and** browser | @@ -206,8 +208,8 @@ The short version: $ python3 -m unittest discover -s tests -t . ``` -**108 tests pass:** 63 language tests, 9 PyHope engine tests, 14 production-app/build tests, -13 workspace/Launcher tests, 8 arcade/Playground site tests, plus a parity harness that runs 25 programs (including error paths) through both the +**112 tests pass:** 67 language tests, 9 PyHope engine tests, 14 production-app/build tests, +13 workspace/Launcher tests, 8 arcade/Playground site tests, plus a parity harness that runs 28 programs (including error paths) through both the Python and JavaScript runtimes and demands byte-identical output. ## 📦 Repo layout diff --git a/docs.html b/docs.html index b6e434f..03c1dba 100644 --- a/docs.html +++ b/docs.html @@ -9,6 +9,7 @@ +
@@ -69,7 +70,7 @@

Documentation

-
+
@@ -508,10 +509,29 @@

Statements

whilewhile running: step() end forfor item in [1, 2, 3]: print(item) end range loopfor i in range(1, 10, 2): print(i) end + recovertry: risky() catch error: print(error.kind) finally: cleanup() end + raiseraise {kind: "ConfigError", message: "port required"} jumpreturn, break, continue +

Structured error recovery

+

Runtime errors are catchable values. A named catch receives a map with + kind, message, line, and trace. + The optional finally block always runs, including during + return, break, and continue.

+
try:
+    result = 100 / divisor
+catch error:
+    print(error.kind + ":", error.message)
+    result = 0
+finally:
+    print("calculation complete")
+end
+

raise "message" creates a UserError. Raise a map with string + kind and message fields to create a named application error. + Syntax errors are detected before execution and are not catchable.

+

Builtins

@@ -519,6 +539,8 @@

Builtins

+ + @@ -596,7 +618,7 @@

Community

GitHubIssuesNews - Events + Events - +
FunctionDescription
print(...)Print values, space-separated
len(x)Length of string / list / map / range
range(stop) · range(a, b, step)Integer range
sum · enumerate · zipIterable aggregation and pairing
all · anyTruth tests across an iterable
str int float bool reprConversions
abs floor ceil round sqrt powMath
min · maxOver arguments or one list
Examplesexamples/hello, fib, fizzbuzz, terminal_raycast
VS Code extensioneditors/vscode/Syntax highlighting + snippets
Dev container.devcontainer/Ready environment for VS Code / Codespaces
Teststests/108 tests: language + app/EXE builder + parity + PyHope + workspace + Playground + arcade
Teststests/112 tests: language + app/EXE builder + parity + PyHope + workspace + Playground + arcade
@@ -370,7 +371,7 @@

Community

GitHub Issues News - Events + Events