Interpreter

Pascal in the browser

Result

                
                
              

Runtime is lazy-loaded. First run downloads Pyodide, then later runs use the warm Python VM.

How this runs a Python interpreter on a static website

The original interpreter is a Python project, but this site is hosted as static files on GitHub Pages. To keep the project real without adding a backend server, this page runs Python directly in the browser through Pyodide, a WebAssembly build of CPython.

The page first renders the editor, controls, and output panels using ordinary HTML, CSS, and JavaScript. The heavier Python runtime is loaded only when the demo is likely to be used: when the demo scrolls into view, or when the Run button is hovered or focused. On first load, the script downloads Pyodide, fetches the interpreter modules from the GitHub repository, writes them into Pyodide's in-browser filesystem, and exposes a small JavaScript-to-Python bridge.

That bridge sends the editor text into the Python pipeline: lexer, parser, semantic analyser, bytecode emitter, and either the stack VM or the tree-walking interpreter. The result is returned to JavaScript as structured JSON, then shown in the Output, AST/Bytecode, and Scope panels.

Demo programs can use READLN(name) for browser inputs. The page detects those calls, builds the small Inputs panel, and substitutes the entered values before passing the source to the current Python interpreter.

Lazy loading matters because Pyodide is much larger than the rest of this site. Loading it only when the interpreter demo is needed keeps the homepage and normal browsing fast, while still letting the live demo run the actual Python implementation rather than a rewritten imitation.