5 ms·
Love this. I'm in the process of creating a language myself, though mine is more for UI. Are you parsing it yourself or are you using something like ANTLR or t
by danielvaughn 3y ago
Love this. I'm in the process of creating a language myself, though mine is more for UI.
Are you parsing it yourself or are you using something like ANTLR or tree-sitter?
- majewsky 3y agoNot OP, but I don't see why one would need to parse this at all. You can just step through the characters one byte at a time and execute them, using only a stack memory for return addresses to implement the [] behavior. No syntax tree needed.
- susam 3y agoThanks! Glad you like it. The sibling comment by majewsky is spot on. There is not much parsing going on. Every character is read one at a time and the turtle's state is changed. Indeed the "[" and "]" commands are implemented with a stack. The entire implementation is a single HTML page written in plain HTML + JavaScript. The evaluation of the code happens here: <https://github.com/susam/cfr/blob/0.2.0/cfr.html#L204 https://github.com/susam/cfr/blob/0.2.0/cfr.html#L204>.
- zx90 3y agoA minimal language for UIs sounds interesting. Can you share any details?
- danielvaughn 3y agoSure thing! It’s still in early development and doesn’t have an engine yet, but the syntax is about 80% scoped out: https://matry.design https://matry.design