Parsing a markup language #292
-
I'm evaluating ohm as a parser for a custom markup language. Currently I'm using nearley.js but I'm having a hard time dealing with non language specific syntax. For example, a my typical markup language will have:
Is there an example of Ohm parsing something similar? I've gone through the basic arithmetic examples but it would help me a lot if there's an example a little closer to what I'm trying to achieve. Any help is appreciated. Thanks, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Yeah, Ohm really needs more examples. For of my projects I needed to pull docs out of source code. Here's the code that does it. I really need to write a blog on it, but the short version is I broke it up into two phases. Phase ONE just looks for the embedded blocks based on the delimiter. In your case you'd need to look for the ^^ in phase one, then do a separate pass for what's inside. I've also done markdown parsers that work similarly. |
Beta Was this translation helpful? Give feedback.
Yeah, Ohm really needs more examples. For of my projects I needed to pull docs out of source code. Here's the code that does it. I really need to write a blog on it, but the short version is I broke it up into two phases. Phase ONE just looks for the embedded blocks based on the delimiter.
/**
and*/
in my case. The semantics returns an array of blocks for the document. Phase TWO then parses the structure inside of the markup.In your case you'd need to look for the ^^ in phase one, then do a separate pass for what's inside. I've also done markdown parsers that work similarly.