-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New definer syntax #16
Open
nickd4
wants to merge
51
commits into
uho:master
Choose a base branch
from
nickd4:new_definer_syntax
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…to bss rather than text section which avoids the need to call mprotect(), rename things
… be wrapped with PROGRAM / END, also removes automatic bye token that was generated by END
…time.seedsource, so that we can run textual forth code without the tests or the banner
… writes to stderr, fix self-hosted tokenizer termination issue (was debugged with eemit)
…ng the nonstandard words on top of gForth's standard words, produces redefinition warnings
…seedForth-i386.pre containing some compiler words so we can do special handling for DTC
…sticated tracing and symbolic debug (via annotated trace) system used to debug the 65C02 port, the trace is also available for the Z80 port and can be used for comparison
…e caller's responsibility to do so if they need to, in the case of "new" this is done by replacing "new drop" with "new h," in the seedForth kernel, whereas in the case of "create" it is done by having the tokenizer prefix the body of the user's Definer-definition with "here h," -- or could make the latter a user responsibility
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently seedForth has a special syntax for defining words, for example
and this is necessary because we cannot really properly handle arguments to Forth words when working via the tokenizer, we can only sort of approximate it with workarounds for common use cases such as defining-words as seen here.
Referring to my last PR "Less use of heads", since I have changed the seedForth
create
primitive to no longer callh,
to create a new head, we need to move this call into the seedForth defining-words, for exampleand I had done a workaround in my last PR where the tokenizer would automatically prepend
here h,
to a definer, e.g.and this preserved seedsource compatibility. But I wasn't really all that happy with that workaround.
So in this PR I am trying a new approach which is more Forth-like, and allows us to define defining-words with a simple
:
, e.g.and the trick here is that
Create
(with a capital C) is now basically an immediate word which pulls some tricks in the tokenizer to mark the current colon-definition (the definition ofVariable
) as a definer. Apart from that, it works kind of similarly to before.The code is well-commented so I will not go into the details of the algorithm here, except to say that:
Definer
in as well, keeping seedsource compatibility;Macro
andend-macro
and might be reused.I have not rewritten all the library code to the new syntax yet, I can do that later if the PR is approved. I used the following test:
versus
Both should emit
BA
.