This gist expands on this Hacker News reply.
The official Jevko spec is meant to be fully generic, but in fact if you don't care about that then you can use this simplifed grammar to start (ABNF + RegExp):
tree = *sub text
sub = text '[' tree ']'
text = /[^\[\]]*/
Meaning:
- a
tree
is zero or moresub
s followed bytext
- a
sub
istext
followed bytree
enclosed in square brackets text
is zero or more characters which are not square brackets
A basic parser for this grammar is less than 50 lines of basic code in any programming language (e.g. 25 lines of JavaScript). No lexer needed.
Once you have a tree structure you can start transforming and then interpreting it!
This is what I've been doing recently with my latest language experiment and it is going rather nicely.
Here is some example code written in this language:
let[
[even?] fn[ [n]
?[
=[ [n] [0] ] [true]
odd?[-[ [n] [1] ]]
]
]
[odd?] fn[ [n]
?[
=[ [n] [0] ] [false]
even?[-[ [n] [1] ]]
]
]
]
even?[10001]
Here is some code written in another Jevko-based language. Lots of brackets you say? Oh, well. But we got identifiers with spaces!
Now once you get the semantics to your liking, you can replace the syntax with something like:
let even? := fn n =>
if n = 0 then true
else odd?[n - 1]
let odd? := fn n =>
if n = 0 then false
else even?[n - 1]
even?[10001]
So yeah. Jevko is pretty fun. I hope you have fun using it.
Cheerio!