mitra42 / webforth Goto Github PK
View Code? Open in Web Editor NEWForth for the web - implemented in JS and other web technologies
Home Page: https://www.mitra.biz/forth/console.html
License: GNU Affero General Public License v3.0
Forth for the web - implemented in JS and other web technologies
Home Page: https://www.mitra.biz/forth/console.html
License: GNU Affero General Public License v3.0
There are a number of places where code and data are mixed, preventing them being separated - e.g. in Rom.
This is a feature of many other Forth's.
Specific known issues ...
Now its working the testing needs fixing.
check not used
Pull any appropriate tests from it to code('TEST')
Enable some way to test the PAD (might be hard in pure Forth ?) see padTestLength and code in test()
Review various test code ... L17-20 variables etc
(depends on #5)
THEN
Provide an optional extra file that has definitions of words in ANS forth as a dictionary, and overrides words with different signatures. A program could then start with "ANS" to switch dictionary to use ANS and then FORTH
I'm at the point in the code where i need to transition to the Forth text interpreter from the JS one.
I think this requires the following steps ....
Should check users - "find" in code currently returns (xt f) which I think came from ANS Forth
"find" in eFORTH is (ca na) | (a 0)
"find" isn't currently working - so debug first
The eForthAndZen version of PARSE is clearly broken - it doens't increment the pointer and eForthOverviewV5 version matches the spec, but clearly the consumers e.g. "(" assume >IN is moved over the parsed string, which it isnt.
For now it is commented out, and the Javascript version kept in use
Maybe a "?" next to the title that goes to README.md for now, then to HELP.md
Also a source link and link to mitra.biz
Get the I/O words working - see TODO-IO
Some variations would be ...
To get find to work, it needs to be able to explore dictionaries
Each name entry consists of CodePointer (to start of code dict entry); LinkAddress (to NA of previous); count+name
THEN
refactor names[] and immediate #6
Should check users - "find" in code currently returns (xt f) which I think came from ANS Forth
"find" in eFORTH is (ca na) | (a 0)
"find" isn't currently working - so debug first ( see below)
Decide if refactor js version
If refactor then make it search dictionary.
We need a way to add new Javascript when extending since jsFunctionAttributes is read once at startup.
Hi - if you are contributing or posting issues, it would be great to introduce yourself in the comments.
Basic goal would be
Each of these steps is likely to be an issue in itself, but this issue is for the overall design.
eForth has provision for data structures for vocabularies but none of the required words.
See https://www.taygeta.com/forth/dpans16.htm for the ANS versions of them, there may be other versions.
Also https://forth-standard.org/standard/search which is basically Vocabulary ANS-ified
ALSO / ONLY are words I've seen but don't have definitions for.
: VOCABULARY CREATE 0 , 0 , DOES> CONTEXT ! ;
also words like ONLY
and ALSO
Recode an alternative using webassembly as the base, rather than Javascript
I'm not familiar with webassembly, other than knowing its stack based, so I'm not sure if/how you program in it directly.
Forth seems to still - after all these years - subscribe to the idea that if one standard is good, then many must be better :-(.
Forth79, Forth83, ANS and probably a few more defacto standards.
Currently the system is based on eForth
and should match those definitions, but that might not be the best solution.
I propose adding some vocabularies that can be used to switch between standards so that a package could for example goANS
at the top and then write in ANS forth. It might not be perfect, but I'm guessing the breaking differences are minor. (e.g. the presence or absence of a word doesn't break anything - just add the word - but the same word with two different definitions breaks things).
Please note any differences in comments and I'll edit this list to include them.
See also for documentation and issues related to specific language variants:
eForth has provision for data structures for vocabularies but none of the required words.
See https://www.taygeta.com/forth/dpans16.htm for the ANS versions of them, there may be other versions.
ALSO / ONLY are words I've seen but don't have definitions for.
Code has had enough changes to be worth a cleanup pass - some items to check are ....
There appear to be a number of tests commented out because they failed for reasons due to the test, not the code.
They need evaluating and either removing or uncommenting.
Attempt at doing input asynchronously as synchronous failed as did simple attempts to yield etc.
THEN
interpret is fragile after it switches to use $INTERPRET
If it sees something it doesn't understand it does a THROW and has no HANDLER to catch that, this resets the stack to something bizarre
STR
interpret('XYZZY') will blow the stack.
Check if should leave !IO converting to RAW - test outside WebStorm
Better handling of memory in preparation for Multitasking or ROMming etc
COLD should do a userInit - etc, and should leave all current definitions still live.
Maybe need to save some variables in userinit space after bootstrap e.g 'EXPECT
Basic idea -
Probably use webcomponents to avoid webpack overhead etc else React
Need ability to do things like
forth.load("https://foo.bar/baz.f") or "./foo.f"
I think there is a standard set of words in ANS Forth - see #12 and ANS 11 or forth-standard.org 11
See also Block Word set ANS 7 or forth-standard.org 7
User initialization is in a JS structure (UserInit) - best to move to COLDD and copy from there.
The console is echoing back to the screen -
STR
123 .S
123 .S
repeated back and th eresult.Look at making top end event driven - only run EVAL via on('data') event,
Hard part will be locking
One way ..... catch event, if buff is non-zero then append, if its zero , then append and start the Loop to evaluate.
Relevant to #22
eForth is missing some words that many users expect to be there.. These include the following (please add comments for anything else missing).
The HTML uses Web Components and index.js uses TextEncoders so they should work in any modern browsers
(Firefox, Chrome, Opera, Edge, Android, but not IE or Safari on IOS or OSX).
There are no plans to support older browsers, however I'll be happy to add PRs if someone else does, I'd particularly like to see it work in IOS.
I tried adding a TextEncoder polyfil - but that didnt work and I'm not familiar enough with debugging on Safari to figure out why ....
https://github.com/anonyco/FastestSmallestTextEncoderDecoder
Write a jsWORD equivalent of WORD
use it to recode ' at ~L583
Need a way to pass events to interpreter.
This will be relevant for #22
There are some places errors aren't handled well ... specifically
See Discussion on ProgrammingForth FB group; proposal in forth-standard.org different proposal in forth-200x . I think (but am not sure) that the forth-standard.org one is more current, but its devoid of usable examples.
Their is example code for {: in forth200x and forth-standard and https://forth-standard.org/standard/locals which depend on system-dependent code.
Current thinking ... subject to any suggestions below .... is to try and implement the forth-standard.org version by implementing (LOCAL) (in JS) and then using the sample code from there for {:
Sticks a lot of stuff on stack, and doesnt display prompt .
Noted that hi is COMPILE-ONLY
but not clear that interpret()
checks that correctly yet, as presumed to be used only during source loading.
Idea is to define //TEST that skips ahead unless testing. and use on all lines ending TEST
Either different versions, or better, a single version with a CELLL size parameter.
m.
or m[
directly@thomas goeppel reported an issue with console not wrapping
Figure out how to make it Multitask, especially light weight multi-tasks.
Need a simple UI element to display the stack
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.