Follow

The Lisp tokenizer works and it is 83 bytes

:)

· · Web · 3 · 2 · 9

You don't need lookahead to deal with lisp, you just need super fuckin lazy parsing.

So like, we don't deal with a number until we find a non-number character, then we execute both the number handling code and the non-number handling code.

This will break at places where you have like, numbers and symbols right next to each other but like... don't do that.

We're not going to have error handling or any nice conveniences because this is literally running in 512 bytes, what do you actually *need*, it should be able to cons two lists together fine. your fault if things crap out because you happened to not type a space

(ha ha only serious)

@powerofzero Oh, it took a few weeks and the original version is written in C, but like it's assembler -- I basically translated it over because C means I can toy with and debug stuff to get the program right, and then I have a baseline to compare against lol

@efi to be fair idk why i added numbers because this is only going to support McCarthy's original lisp constructs which are like five different functions none of which deal with numbers

@efi but also yes a negative number will fuck up because we straight up do a shitty tiny hash on the input symbol, so it will start hashing the minus sign, and then multiply that by ten and add the number to it, because it would waste bytes checking the state beforehand

@alexandria nice! In my OS project I used to have a super simple parser where every token had to be separated by whitespace, sounds like your version is already more powerful :P

(Which assembly by the way, x86?)

@Vierkantor oh lol, I don't think it's that much more powerful given the overall size of the code :blobsmilesweat:

It's designed to run in x86 real mode but I'm testing it out in DOS since DOSBOX has an actual debugger where i can step through and see the code and data segments :)

Sign in to participate in the conversation
Cybrespace

cybrespace: the social hub of the information superhighway jack in to the mastodon fediverse today and surf the dataflow through our cybrepunk, slightly glitchy web portal support us on patreon or liberapay!