5 ms·
Is it really unambiguous? There is no grammar, but the spec describes things in English. It's really hard to avoid ambiguities and impossible to proof unambiguo
by legulere 10y ago
Is it really unambiguous? There is no grammar, but the spec describes things in English. It's really hard to avoid ambiguities and impossible to proof unambiguousness without formal methods.
- Ajedi32 10y agoI guess it's hard to say for sure that it's completely unambiguous, but that's definitely the intent. [The spec][1] even says: > This document attempts to specify Markdown syntax unambiguously. So if you're aware of any ambiguities in the spec, those are bugs which should be reported and fixed. [1]: http://spec.commonmark.org/0.27/ http://spec.commonmark.org/0.27/
- the_duke 10y agoYou may want to work on specifying a formal grammar in EBNF or similiar. Great for library / parser implementers and it helps discover ambiguities.
- taylorfausak 10y agoFrom John MacFarlane, the author of the CommonMark spec: > If anyone wants to contribute a BNF, please do! But I'm very skeptical that it can be done, due to the many quirks of the syntax. https://github.com/jgm/CommonMark/issues/113#issuecomment-60467783 https://github.com/jgm/CommonMark/issues/113#issuecomment-60...
- dozzie 10y agoSo it's basically as useless for general processing as Markdown, because you won't have a grammar from which you can generate parser, hence all the parsers will be handcoded with various quirks differing from one to another and none of which will produce a parse tree.
- marcosdumay 10y agoIf it's hard to write a BNF, it's also hard to write a parser.
- mrottenkolber 10y agoI'm baffled. Without a formal grammar CommonMark is useless. Who implements a parser without a formal grammar?
- the_duke 10y agoIf the syntax has so many issues that you can't specify a formal grammar, there's a problem with the spec.
- gsnedders 10y agoBNF doesn't make something unambiguous. I mean, Foo = "hello" / "hello" is totally acceptable, and if you have any indirection like Foo = XXX / YYY with XXX, YYY = "hello" you can then attach different semantics to XXX and YYY despite it being ambiguous. Add in more levels of indirection, and you have a lower chance of it being trivially obvious.
- legulere 10y agoBut there exist tools to help you decide wether a grammar is unambiguous when you have a formal grammar: https://en.wikipedia.org/wiki/Ambiguous_grammar#Recognizing_ambiguous_grammars https://en.wikipedia.org/wiki/Ambiguous_grammar#Recognizing_...
- akavel 10y agohttp://vfmd.org http://vfmd.org has an exhaustive and unambiguous formal spec for (a variant of) Markdown. As a bonus, it's easy to understand, nicely extensible, and has an example implementation. The only drawback I'm aware of is that it seems routinely ignored by nearly everyone. I wonder why?
- legulere 10y agoWhile the spec is way more formal, it's still not in a form that easily lends for a proof that it's unambiguous.
- wolfgke 10y agoI have not looked into the details of the grammar, but proving that a grammar is unambiguous is typically done by proving that it is in, say, LL(1) or LR(1) (or some related family). This approach towards unambiguity has the additional advantage that it is easy to derive a parsing algporithm directly from the grammar that has nice theoretical properties (e.g. linear parsing time in the input length; where the hidden constant depends on the grammar).
- legulere 10y agoThere is no grammar, it's a description how to parse markdown using regexes.
- deleted 10y ago[deleted]