Open
Conversation
…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)
6488759 to
913f5dd
Compare
This file contains hidden or 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
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.
This implements a new hash table arrangement in
seedForth-tokenizer.fs. If I understand the previous code correctly, I think it makes a bit of a simplification in that it allocates a large hash table to make collisions unlikely, but can't then handle collisions.So with the new method I have allocated a 1024-entry symbol table and I'm using closed hashing, in which a CRC function gives the preferred entry for a given symbol, but if that entry is occupied by another symbol it looks circularly for a free entry.
The main reason why I wanted to make this change is so that the tokenizer can be self-hosting on Z80, which does not have the memory for a large hash table. With the new way, there's no reliance on 32-bit arithmetic either, which is useful for Z80.
The choice of a 1024-entry table is due to a change I made in the last PR which freed up token 3 for additional token space:
It would of course be easy to make the table larger on a target like i386 that can support it. If so, then the current CRC10 could be changed to say CRC12 or CRC16 (I really hate the idea of calculating a CRC and then masking it off to lose its properties!).
Note: There are minor bugs in this PR, as follows:
gforthinMakefileinstead of$(HOSTFORTH). It is fixed in Z80 port (cleaned up version) #12 so I have not fixed it here.Macroandend-macro, and could be reused by accident, though it would be unlikely. It is fixed in New definer syntax #16 so I have not fixed it here.If you do want the fixed version of this PR see the branch
tokenizer_hash_table1in my github account. I wouldn't recommend using that branch though, because it will cause conflicts later when mergining #12, #16 and others.