World’s most tiny blogparser written in MGrammar
My first small parser I’ve written in MGrammar. Nothing fancy though..
I’ve defined the way I’d like to create my blogs, posts and blogrolls in a textual way:
Blog With Title OsloBlog Section Posts Post With Title MGrammar And Desc MGrammar Post With Title Quadrant And Desc Quadrant End Section Section Blogroll Link With Title Oslo And Url http://microsoft.com Link With Title Michael And Url http://michaelwolbert.nl End Section End Blog Blog With Title MichaelBlog Section Posts Post With Title Avanade And Desc Ava Post With Title Testing123 And Desc Testing123456789 End Section End Blog
With our grammar (parser) we can now create projections of our textual DSL:
Blog[ Title[ "MichaelBlog" ], Sections[ Posts[ Post[ Title[ "Avanade" ], Desc[ "Ava" ] ], Post[ Title[ "Testing123" ], Desc[ "Testing123456789" ] ] ] ] ]
Next step would be to push this projections to Oslo’s repository (just a plain ol’ SQL 2008 database), so a runtime can access it. We could also create a runtime which uses a set of classes to parse our textual DSL directly to the runtime. But that will be covered later on.
See this Intellipad screenshot for the textual DSL, the MGrammar and the projections (from L to R).
Some nice samples can be found in the “M” Language Gallery. Especially Natural Language Dates has some good pointers to get started.