97 points · by nils-m-holm · 9y ago · 51 comments
Unlike this recursive-descent parser, my minimalistic language uses a table-driven shift-reduce parser which is entirely contained in the C code. Both the lexer and the parser can be extended very easily in order to accommodate new tokens and new syntactic forms.
This looks like it's a MISC: https://en.wikipedia.org/wiki/Minimal_instruction_set_comput...
I've also invented something like this: NISC. (Or {}ISC) Null Instruction Set Computer. You can arbitrarily reduce the die size for implementations of this architecture, as well as scale the clock speed arbitrarily. It also revolutionizes cooling.
A formal notion of a minimal language/machine gets messy anyway and is of limited utility even in a purely academic context, as far as I know.
it's kind of insane how little you need to do computation.
How is this able to omit basic type information? Is everything just an int?
> "It is a statement rather than a production tool."
What's the statement supposed to be?
Data is untyped and operators are typed. So in X+Y, X and Y are integers, in X::Y, X is a byte vector and Y is an integer, and in Y[X], X is an integer and Y is a vector (and the types of its element again depend on the operators applied to them).
Note that not all combinations of data and operators make sense. E.g., "foo"*[1,2,3] is a valid expression, but probably will not deliver any meaningful result.
I'll leave the interpretation of the statement to you! ;)
http://brinch-hansen.net/papers/1981b.pdf
He did lots of interesting stuff including a race-free language for concurrency:
I have written compilers for lots of different processors and virtual machines with varying key aspects, like compilation speed, memory footprint, executable size, etc.
Check out my home page (http://t3x.org), there compilers for many different languages, from mainstream to pretty exotic. There are also excerpts from many of my books and even the full texts of some of the older ones.
For now, you can download the full text of "Lightweight Compiler Techniques" here: http://www.bcl.hamilton.ie/~nmh/t3x.org/zzz/lightweight-comp...
Enjoy!
You can also use it to bootstrap something more high-level than assembly language in very little time.
I have even written real-life programs in T3X for a while, but I wouldn't recommend it unless you are fascinated by the beauty of typeless languages!
By bootstrapping, I'm referring to building a T3X9 compiler for a new target platform and than using that to create something more interesting. You can start the process by re-implementing the compiler or by re-targeting it.
If you look at the source code, you might learn something.
>The compiler translates from T3X9 directly to FreeBSD-386-ELF. It does not require any assembler, linker, or other additional programs. I suspect that it can be ported to other 32-bit ELF Unixes in about half an hour.
Not judging the language itself, but that is not really convincing.
That being said: yes there are problems with the comments. It's code I have written decades ago and just copy-pasted now. Will fix! Thanks!