(Are you tired of seeing only webdev posts on this site? At least I absolutely am.)
This side project idea has been sitting in my to-do list for way too long. Now that I’ve finished the core of my lexer generator I would like to test it out on something simple, so…
Design By Numbers is an educational programming language designed by MIT professor John Maeda in the late 1990s which later spawned the much more famous Processing. Unlike Processing, the source of Design By Numbers was never officially released to the public. I don’t have the book by Prof. Maeda so I am forced to have some speculation on the actual language design I guess…
I spent a little time figuring out the plan:
- I’ll try to figure out – and decide, if need be – what exactly is the language’s syntax, grammar and semantics.
- I’ll write an interpreter for the DBN language, pretending I’ve already implemented all the actual drawing subroutines. To test things out I’ll have placeholders, e.g. instead of actually drawing a line I’ll have it print out
DrawLine <x1> <y1> <x2> <y2>in the console.
- Then I’ll actually implement all the drawing subroutines using the Canvas API.
- And maybe I’ll write about the process idk.
I wrote it as a part of my toolset because I can’t quite figure out how to fit other tools like ANTLR into my workflow (and my mind does not like reading other people’s code & configurations)
The core idea of the lexer generator is:
- Most programming languages’s lexical structures can be described with a bunch of regexps.
- You can “compile” this bunch of regexps into a nondeterministic finite automaton (NFA) using some construction algorithms.
- AFAIK this is probably how (at least some) regexp engine actually works; the NFA structure might not be explicit but the spirit will be there.
- The NFA:
- can be further generated into something like this.
- can be directly executed with some automata traversing algorithm.
- or bundled with the actual code of the traversing algorithm.
Combine these facts together and voila you have your very own lexer generator. It’s actually not that hard once you understand. No I won’t be releasing it before completing the whole thing… DBN is such a simple language you probably won’t need any sophisticated tool anyway.
I’ve read the introduction but DBN isn’t a real programming language (at least not as “real” as something like Python), then what’s the point?
Well, if you have to put it that way…