Concatenative topics
Concatenative meta
Other languages
Meta
Meow5 is a programming language experiment written in NASM assembly and targeting 32-bit i386 Linux. Its syntax is very similar to Forth.
It is "concatenative" in two senses:
Meow5 can run programs in the interpreter interactively and can also write those programs (or any named portion of them) to disk as stand-alone Linux ELF executables.
This example shows two defined routines: meow
prints a "Meow!" with newline, meow5
is composed of five calls to meow
. This interactive session shows both the programmer's input and the result:
def meow "Meow!\n" print ; meow Meow! def meow5 meow meow meow meow meow ; meow5 Meow! Meow! Meow! Meow! Meow!
Meow5 can be asked to "inspect" the "defs" (definitions) by name:
inspect meow meow: 45 bytes IMMEDIATE COMPILE e8 7 0 0 0 4d 65 6f 77 21 a 0 58 50 50 58 b9 0 0 0 0 80 3c 8 0 74 3 41 eb f7 51 5a 59 bb 1 0 0 0 b8 4 0 0 0 cd 80 inspect meow5 meow5: 225 bytes IMMEDIATE COMPILE e8 7 0 0 0 4d 65 6f 77 21 a 0 58 50 50 58 b9 0 0 0 0 80 3c 8 0 74 3 41 eb f7 51 5a 59 bb 1 0 0 0 b8 4 0 0 0 cd 80 e8 7 0 0 0 4d 65 6f 77 21 a 0 58 50 50 58 b9 0 0 0 0 80 3c 8 0 74 3 41 eb f7 51 5a 59 bb 1 0 0 0 b8 4 0 0 0 cd 80 e8 7 0 0 0 4d 65 6f 77 21 a 0 58 50 50 58 b9 0 0 0 0 80 3c 8 0 74 3 41 eb f7 51 5a 59 bb 1 0 0 0 b8 4 0 0 0 cd 80 e8 7 0 0 0 4d 65 6f 77 21 a 0 58 50 50 58 b9 0 0 0 0 80 3c 8 0 74 3 41 eb f7 51 5a 59 bb 1 0 0 0 b8 4 0 0 0 cd 80 e8 7 0 0 0 4d 65 6f 77 21 a 0 58 50 50 58 b9 0 0 0 0 80 3c 8 0 74 3 41 eb f7 51 5a 59 bb 1 0 0 0 b8 4 0 0 0 cd 80
The alarming output above is the raw i386 machine code of each definition. Upon closer inspection, you'll note that the contents of meow5
is precisely 5 concatenated copies of meow
.
This program can be written to disk as a 317 byte Linux executable. (A looping version that produces the same output is a mere 160 bytes!)
Meow5 has three syntactical rules:
"foo"
), escape sequences and interpolation are supportedThe built-in library of defined routines is very small and contains a mixture of high-level and (extremely) low-level functionality, any of which can be replaced interactively.
The all
definition lists all current definitions:
all elf get set var loop? ? ? dup pop dec inc / * - + all inspect ps printmode say print$ printnum number decimal bin oct hex radix str2num quote num2str ; return def copystr get_token eat_spaces # get_input find is_runcomp get_flags inline print strlen exit
Note that the #
character is used as a comment, but it is not part of Meow5 syntax. Instead, it appears in the list of definitions above. A programmer can replace it or add other "syntactical" elements like it as desired.
External Links:
This revision created on Thu, 25 Apr 2024 18:56:42 by ratfactor (Added clarification)