Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I really wish their was concise formal spec for markdown, rather than a multi-page essay. It makes it incredibly difficult for anyone trying to create something to parse it. There is no mechanical way for go from spec -> parser.

I think its quite difficult to do though.



Is there any common spec where you can mechanically go from spec to parser? HTTP, SMTP, DNS, HTML, CSS, Javascript, Ruby, Python, C, ... I basically know of nothing in widespread use with a spec that can actually be converted directly into working code.


Does implementing TCP/IP stack using the RFC (as in parsing diagrams straight from RFC) counts?

Then it was done in OMeta [1].

Previous discussion: A full TCP/IP stack in under 200 LoC (and the power of DSLs) [2].

There's also a PNG parser (but it is not parsing any documentation) in 20 lines of OMeta [3].

[1] http://www.moserware.com/2008/04/towards-moores-law-software...

[2] https://news.ycombinator.com/item?id=846028

[3] http://joshondesign.com/2013/03/18/ConciseComputing


For the parser itself, yes. There are parser generators that take a spec(BNF, PEG) and output a parser that can parse the language.

What you do with the parsed tree is up you though.


Is it really useful to write a formal spec for Github Markdown? The software they use to parse and render it is open source. If you want to know how exactly something works, you can read the source.


Is it really useful to write a formal spec for HTML? The software we use to parse and render it is open source. If you want to know how exactly something works, you can read the source.

;)


Having used and maintained a Swift translation of the StackOverflow .NET markdown processor, please, when there is a proposal to use source as a spec, burn it with fire. Scatter the ashes.


Yes, if you also want to have more implementations, that can differ in e.g. license or programming language.

For instance it is the reason why there's no reimplementation of TeX.


There is pdflatex, luatex,...

Nobody stops you from translating the Ruby or whatever into your favorite language.


Reading the sources and trying to understand it takes a lot longer than looking at bnf and cranking out recursive descent parser based on it or a parser generator.


It's not possible to write a BNF for Markdown. At least not an unambiguous, useful BNF.

http://roopc.net/posts/2014/markdown-cfg/




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: