Skip to content

Can we write EBNF for djot? #209

Answered by matklad
shi-yan asked this question in Q&A
Feb 20, 2023 · 1 comments · 6 replies
Discussion options

You must be logged in to vote

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.

But I need to extend djot's syntax to support more features

Could you te…

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@matklad
Comment options

@matklad
Comment options

@shi-yan
Comment options

@hellux
Comment options

@shi-yan
Comment options

Answer selected by shi-yan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants