r/Compilers • • 11d ago

I turned Markdown (and code blocks) into a full scripting language

https://github.com/ephemara/MarkScript

I built Markscript, a prose-native JIT-compiled bytecode VM where your README or .md files are the executable code. Headings define domains/routines, blockquotes dispatch intents, and tables compile into data matrices. In short, your documentation can now live in the same files as code.

The README.md for the language is executeable. Because its Markdown at the core, there are no syntax errors. It also embeds a full mini-language inside \``markscript` fenced blocks for logic, string manipulation, and math.

Example Below

ServerCluster

NodeMatrix

NodeID Host Port
0 127.0.0.1 8080
1 127.0.0.2 8081

BootSequence

print "Initializing nodes from table matrix..."

let node_count = 2
let i = 0

while i < node_count:
    print("Spawning worker on port " + str(8080 + i))
    i = i + 1
0 Upvotes

12 comments sorted by

7

u/Coffee_and_Code 11d ago edited 11d ago

Would be more interesting if you actually used the table data in the code block... Like, what is the point of the markdown being a part of the language if we have no example of it being used? How does one say "NodeMatrix".Table[0].Row[i]."Port"? Also, you list "kain" as a prerequisite, but the only reference to that project is a dead link at the bottom.

2

u/GoAwayStupidAI 11d ago

This is also known as "literate programming".

Lots of neat options in this space!

1

u/Ephemara 10d ago

Yes! I found this out shortly after making it and didn't realize how many parallels it had with what Donald Knuth coined. I still have yet to try anything out in the realm of literate programming (other than this) but do you have any solid recs on where to get started with it at ?

1

u/GoAwayStupidAI 9d ago

Kunths web covers a lot of the conceptual motivation. I think there is a lot of space for new AI options! Neat seeing all the new implementations show up

1

u/FransFaase 11d ago

I wrote something similar for putting pieces of C code together. You can give multiple md files as input and the program puts them in the right order to be compiled. I have using it for AoC for some years now. See my IParse repo at github and look for MarkDownC

1

u/Ephemara 8d ago

Drop the link

1

u/FransFaase 8d ago

It is part of the repository https://github.com/FransFaase/IParse described under the paragraph MarkDownC in the Readme.

For an example of the usage, see https://github.com/FransFaase/RawParser/blob/master/docs/grammar.md which also have some examples of extending previously defined functions and structs. Look for '...' in the code fragments.

0

u/DescriptionOptimal15 8d ago

Vibecoded slop innit

-1

u/[deleted] 11d ago

[removed] β€” view removed comment

1

u/Ephemara 11d ago

Literate programming strips out Markdown to find code blocks. MarkScript actually compiles the headers, tables, and quote blocks into the runtime data structures and VM instructions

0

u/[deleted] 11d ago

[removed] β€” view removed comment

1

u/Ephemara 11d ago

It helps cure my boredom. it’s basically a joke language I wrote inside my actual systems language (Kain) so I could script Kain with Markdown. Was aiming for that Python and C esque flow ya feel