StackLang, part 2: lexing.
It’s quite often the simplest part of implementing a programming language (although parsers for s-expression based languages come close), but it’s still something that needs done. So here we go!
StackLang, part 2: lexing.
It’s quite often the simplest part of implementing a programming language (although parsers for s-expression based languages come close), but it’s still something that needs done. So here we go!
I enjoy writing programming languages. Example: Tiny. Let’s do that again.
This time, StackLang:
{
@[n fact]
1
{ n 1 - $fact fact n * }
N 1 <= if
} @fact
5 $fact fact writeln
Bit of gibberish there, I suppose, but the goal is to write everything in a postfix/stack based model. So n 1 - $fact fact n * is equivalent to fact(fact, n - 1) * n in a more traditional language.
Over the next few posts, I hope to write up where I am thus far and what’s next.
Recently, I read through Build Your Own Redis with C/C++. C/C++ are ugly, so let’s run through it in Rust!
My goal: implement some large subset of Redis (both server and client) in Rust. For any features I implement, it should be compatible with Redis off the shelf. I should be able to use their client with my server and their server with my client and it should just work.
No idea if this is going to work out, but it sounds like an interesting problem!
First task: the REdis Serialization Protocol (RESP).
Given a series of equations of either the form
dbpl: 5orcczh: sllz + lgvd, determine what the value of the node labeledrootis.
Given a list of 1x1x1 cubes, determine the total surface area of the cubes.
Given a grid of numbers, count how many of these numbers have a direct path in any cardinal direction to the edge of the grid.
Given input as a list of characters, find the index of the first sliding window (size 4) where all of the characters are distinct.
Given a list of stacks of syntax 1 and instructions in the form syntax 2, apply each instruction to pop
qtyitems from the stacksrcand put them ondstone at a time.
Syntax 1: Stacks
[D]
[N] [C]
[Z] [M] [P]
1 2 3
Syntax 2: Instructions
move 1 from 2 to 1
move 3 from 1 to 3
move 2 from 2 to 1
move 1 from 1 to 2
.), east movers (>), and south movers (v). Each step, move all east movers than all south movers (only if they can this iteration). Wrap east/west and north/south. How many steps does it take the movers to get stuck?w, x, y, and z) and instructions defined below. Find the largest 14 digit number with no 0 digits which result in z=0.