the ~karx journals

various musings of ~karx

from cup import coffee (sandwich devlog #4)

February 16, 2021 — ~karx

In today’s sandwich-making adventure, I improved the comment parser. Not you can use comments inline. For example:

# this is a comment
pHello #this is an inline comment
pWorld # <- Will print World!

the # symbol turns the rest of the line into a comment, so be careful! Everything before the comment symbol will be evaluated.

I also added the ability to import things from other files with the i opcode, like so:

#one.txt
pHello world!

itwo.txt# now everything from two.txt will be imported into one.txt
p$v #v is defined in two.txt

And the external file would look like this:

#two.txt (external)

lvsome variable

So the output would be “some variable”. Note that the file is evaluated before importing, like in Python. This means that any print statements or math operations in the file that are not enclosed in a variable or a function will be executed like a normal program.

As always, the code is up on tildegit, so clone a copy and get started with sandwich! PRs can be made on Gitea or sent to my tilde.team email (karx AT tilde DOT team) as patches.

tags: sandwich, rust, programming, devlog