#My First Ever Bytecode Interpreter

34 messages · Page 1 of 1 (latest)

half anchor
#

Here's my preferred leisure project in C++. I aim to create a small, imperative utility language for personal usage. Also, I dislike *nix shell script syntax so here I am.

Pre-Notes:

  • The runtime is a stack based VM with naively generated bytecode.
  • The Semantic analyzer is partly done. Type checking seems alright for now, but constness checks are to-do.
  • See the Roadmap for my long-term plan. Feel free to remind me to continue this, and I'll chip at it whenever I can.

Repo:
https://github.com/DrkWithT/ExpliceLang

GitHub

A small, imperative, toy language for utility and fun. WIP - DrkWithT/ExpliceLang

somber pollen
#

Nicely done 🙂

celest marsh
#

epic

magic raven
#

Oh nice! I've starred the repo -- did you follow a book like Crafting Interpreters or anything like that?

half anchor
magic raven
#

Definitely going to be taking a look at your impl -- that's kinda what I'm working on right now too

half anchor
#

I've added a semantic analyzer which detects undeclared names, return types vs. enclosing procedure result types, and some expression type checking.

It's now passing test sources up to test_3e

rain jay
#

nice job

half anchor
#

Currently working on adding native functions
now it's time to build and test even more...

half anchor
#

Native functions (added to the VM instance in native code) now can be pre-declared as "used". Now I can print numbers.

half anchor
#

Will start working on while loop support. The only regret I have is making my IR steps 1 to 1 against my bytecode, so I'll have to refactor more of the codegen for complex reasons. nooo

half anchor
#

After some fixes for codegen, I can say that while loops are starting to work. Test 5 passes now, but I'll add more complex tests later.

jovial stratus
#

what are those trailing commas for in the arguments?

half anchor
#

I'm on the fence about this design decision. Trailing commas look a bit weird coming from most other languages, but I was trying to get a minimal program running at first, resulting in shortcuts being taken. But I may enhance the parser later to have better error messages too.

willow verge
#

youll probably want them to be optional

#

also nice project!

#

looks good

half anchor
#

Got a simple array iteration to work, and this program running in the image is a debug build.

willow verge
#

very nice!

half anchor
#

After ~6 hours of on/off refactoring and debugging, I have got my compilation logic and VM to handle imported procedures from other "TUs". It is 4am rn, time to crash out. 😴

#

My biggest regret was hardcoding things to only address one source file in any program in the toy language.

half anchor
#

I'm on hiatus for now (just passed summer midterms). I'll be back working on this possibly next week or so, and when I do, I'll continue by the roadmap.

willow verge
#

same thing here

#

working on my AST for my c compiler

half anchor
#

Just returned to the project this morning and managed to remove trailing commas from the syntax.

#

Will update the main branch later

celest marsh
#

yey

half anchor
#

Up next if I can find a lull in my summer homework...
Improve parser error messages to notify what are "expected" tokens for certain bits of syntax (0.7.1b)

sour stratus
#

Pretty good code

willow verge
#

i went through the code for your interpreter. looks very organized and clean to me! good job so far

half anchor
willow verge
#

sounds like a fun project too

half anchor