-
Notifications
You must be signed in to change notification settings - Fork 12
Actual interpreter for microcontroller? #18
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
Comments
The intention is for code to be compiled for the microcontroller from C - that way small microcontrollers can be used without the overhead of an interpreter. Maybe the word scripting is misleading here(?). I'm planning to explore actually running Cognate on a microcontroller once I've got the new compiler feature complete and stable. |
I was worried of that. What I want to do is hook up the microcontroller directly to a storage device (flash drive, SD card, etc), have it read the |
Ah yeah that'd be a problem with the current implementation. I'll almost certainly ship a small interpreter with the new compiler once it's done, but CognaC in its current iteration won't be much help here, sorry! |
Hey Finn -- don't know if you're interested, but I have been starting work on a "pure" interpreter for Cognate that runs the code without having to transpile it to C first. I just put it on GitHub: https://github.com/dragoncoder047/cogni In its present state it isn't able to run anything, but it is able to parse the prelude without errors. Hopefully I'll be able to get it to working status soon! |
Wow, that looks incredibly cool! The source looks a fair bit neater than CognaC's too lol. Please keep me updated :))) |
It can now do this: $ ./cogni -c "Print \"Hello, World\""
Hello, World Slowly getting there... |
Nice! |
What did you intend for
Also, why is the function that handles invoking unexpired continuations called |
Call/cc is the ideal and what I was originally going to implement for |
Call/cc is the ideal and what I was originally going to implement for |
Regarding tables / hash maps: It doesn't look like tables (or lists for that matter) are mutable, because both |
They're closer to |
A monumental update: Cogni now passes all of the tests! (Or, all of the ones that don't depend on how something is printed or ordered.) Including the regex and IO functions! It's still pretty slow, but I'm working to make it faster. Currently, the environment is using an assoc list instead of a table, so it's O(n) for lookups because an assoc list is effectively a BST that's always completely unbalanced. I tried swapping out the environment for tables (in another branch, not main), but now this happens:
I suspect a hash collision or something... will have to investigate further. |
Oh nice! I've just tested it on my machine and it works too (although Would you like me to add a link to Cogni on the Cognate website? |
I considered that, but the GC I made serves two purposes: 1) it only uses malloc/free, so it can (in theory) run on microcontrollers like the esp32 that don't have
Of course! |
Ohh those are some very good points about the GC. I'll add the link on the website now. |
I've added the link to the website and the github readme :))) |
From the readme:
... but microcontrollers can't compile and run C. Is there a "pure interpreter" for a microcontroller somewhere that actually executes the code instead of transpiling it to C? If there isn't, how do I make one out of this code here?
The text was updated successfully, but these errors were encountered: