-
I have a n00b question that if we can write EBNF for djot. I want to use djot as the file format for my notebook app. But I need to extend djot's syntax to support more features. I looked at some of the djot implementations, they are too obscured to modify. I hence wanted to write one from scratch. I'm not experienced in parsing. Previously I have used some parser generators briefly. I understand one design goal of djot is making parsing easier, I'm wondering if we can write EBNF for djot? (if so I will consider using tree-sitter to create a parser) thanks, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
Practically, my gut feeling is that a grammar won’t be very useful for djot (or in general for light markup languages). The structure is much more shallow (few distinct syntactic constructs), any input should have a parse tree, and there are a bunch of 2D rules (indentation, block quotes). So I’d probably recommend doing what djot.JS implementation does (parse blocks using sort-of-recusive descent maintaining a stack of blocks, witching each block parse inlines maintaining a map of potential openners). Theoretically, I think djot isn’t LL(k) (because of attributes and rules for emphasis), but it might be LR or PEG.
Could you tell which features exactly do you need? One big idea of djot is that you shouldn’t need to extend its syntax, as div, spans, and attributes should be enough to express any custom functionality within djot’s syntax. |
Beta Was this translation helpful? Give feedback.
Practically, my gut feeling is that a grammar won’t be very useful for djot (or in general for light markup languages). The structure is much more shallow (few distinct syntactic constructs), any input should have a parse tree, and there are a bunch of 2D rules (indentation, block quotes). So I’d probably recommend doing what djot.JS implementation does (parse blocks using sort-of-recusive descent maintaining a stack of blocks, witching each block parse inlines maintaining a map of potential openners).
Theoretically, I think djot isn’t LL(k) (because of attributes and rules for emphasis), but it might be LR or PEG.
Could you te…