Native Shell
Native Shell:AI 生成的 UI,在你的應用中原生呈現,涵蓋每個平台。iOS、Android、macOS、Windows 與 Linux 上的應用、GPUI 應用與網頁在執行時載入已簽名、沙箱隔離的 TSX 模組並繪製 th
AI 翻譯
尚未偵測到更新。GitHub 發布版本後會顯示在這裡。
個人 GitHub 帳號下公開儲存庫的擁有者可以登入並驗證所有權,自行管理介紹,無需管理員核准。
登入並產生驗證檔案,在 30 分鐘內將其提交至此儲存庫的預設分支。其他分支或分叉儲存庫中的檔案無效。然後在下方檢查檔案,即可無需管理員核准直接管理專案。請保留檔案以維持管理權限。
如需登入,將前往登入頁面。登入後請回到此處,再次點擊所選的驗證按鈕。
在專案資料夾中執行 /nomorevibe verify,即可驗證所有權並自行管理介紹。
一分鐘完成驗證A small, mostly standard Forth in the browser: compiled words, return stack, DO/LOOP, BEGIN/WHILE, CREATE DOES>, live stack view. Zero dependencies.
翻譯準備中
取自儲存庫 README
正在載入完整 README。
檢視完整 README ↗A small Forth that runs in the browser, close to the standard. Colon definitions are compiled, there's a real return stack and proper control flow, and the terminal shows the data stack live. There are no dependencies and no build step.
Live demo: https://cstroie.github.io/forth/
2 3 + . \ 5
: square ( n -- n*n ) dup * ;
7 square . \ 49
: countdown ( n -- ) begin dup . 1- dup 0= until drop ;
5 countdown \ 5 4 3 2 1
Type help for an overview, words to list every word, and see name to show a definition. The Examples panel loads ready-made programs:
CREATE … DOES> arraysmsCASE and KEY<# #>| Area | Words |
|---|---|
| Stack | dup drop swap over rot -rot nip tuck pick roll ?dup 2dup 2drop 2swap 2over depth clear >r r> r@ |
| Arithmetic | + - * / mod /mod */ negate abs min max 1+ 1- 2* 2/ and or xor invert lshift rshift random |
| Comparison | = <> < > <= >= 0= 0<> 0< 0> u< within true false |
| Output | . u. .r .s ? emit cr space spaces type ." .( page / cls, decimal hex binary |
| Control | if else then, do ?do loop +loop i j leave unloop, begin until again, begin while repeat, case of endof endcase, recurse exit |
| Defining | : ; variable constant value to create allot , c, does> ' ['] execute literal char [char] |
| Memory | @ ! +! c@ c! 2@ 2! here cells cell+ chars char+ 2variable 2constant |
| Compiler | immediate postpone [ ] literal compile, marker forget |
| Formatting | <# # #s hold sign #>, s>d d. |
| Input and time | key key? accept ms |
| Floating point | f+ f- f* f/ f** fnegate fabs fsqrt fsin fcos ftan fatan fexp fln flog floor fround fmin fmax, fdup fdrop fswap fover frot fdepth, s>f f>s f= f< f0= f0< f. f.s pi f@ f! fvariable fconstant |
| Strings and comments | ." text", s" text", ( comment ), \ comment |
| Tools | words see help cold |
| Storage | save name, load name, files, delete name |
How it behaves:
true is -1. / and mod round toward negative infinity (floored division).1.5, 2e0) is a float.base. A prefix overrides it: $FF is hex, #10 decimal, %101 binary, and 'a' is a character code.ABORT does. The message points at the word that failed, for example 2 3 >>>foo<<<.key waits for a keystroke, accept reads a typed line, and ms pauses without freezing the page.Tab completes word names. ↑/↓ scroll through history. Esc or Ctrl+C interrupts a runaway word: the interpreter runs in time slices, so begin again can't freeze the page.cold starts from scratch.The page is a Progressive Web App. Your browser offers to install it (on a phone, use Add to Home Screen). After the first visit it also works offline: a service worker (sw.js) caches the app and refreshes it in the background, so updates appear on the next visit.
forth.js holds the interpreter: outer interpreter, compiler, inner interpreter and the built-in words. It doesn't touch the DOM, so it can run in Node:
const { Forth } = require('./forth.js');
const storage = { get: () => null, set: () => true, remove() {}, keys: () => [] };
const f = new Forth(text => process.stdout.write(text), storage);
f.enter(': sq dup * ; 12 sq .');
f.runSlice(); // prints "144 ok"
index.html holds the terminal user interface.
node --test
The tests run the interpreter core under Node (version 18 or later) with no dependencies. GitHub Actions runs them on every push.
This started as a fork of eatonphil/jsforth (2013–2015), a micro-Forth Phil Eaton wrote for a programming-languages course. Version 2 is a complete rewrite. The original passed words around as strings and re-interpreted them; this version compiles definitions into code, runs them on an inner interpreter, and uses standard Forth behaviour throughout.
Programs saved with the old save command can still be loaded with load.
MIT. Original © Phil Eaton, rewrite © Costin Stroie.