MGrammer : My first languange

During my browsing i found the PDC 2008 video’s and was so excited to see new microsoft products like OSLO SDK and M language family. Finally i decided to give a try of my own using the MGrammer for writing my first language.


Presently we are using the UI below for search using dropdown’s and TextBox’s for criteria and also it was limited to only two search criteria becuase of real estate issue.

Finally i was enlighted by MGrammer that why not have my own language which would allow user to write there query. Here is what i got 🙂 

The only reason i posted the example above is to show how MGrammer is helpful for simple problems. I have been part of various projects in past where power users of the application wanted to perform some operation which is simply not possible with conventional UI e.g. once a user asked for capability to write Select statement in the UI which was not possible because user can delete or update the data by mistake. Also DBA’s would not allow write access in the hands of application user’s.


If i am faced with the same problem again i would write my small language which would allow minimum operations from the UI and let the user write subset of SQL queries.

Finally the MGrammer for the above implementation.

module PDC {


language Contacts


syntax Main = Search;
syntax Search = SearchToken Clause WhereToken Args;
syntax Clause = “PolicyHolder” “Associate” “AccountManager”;
syntax Args = (Arg isToken value)*;
syntax value = (‘A’..’Z’ ‘a’..’z’ ‘0’..’9′)*;

syntax Arg = “Policy” “Name” “SSN”;

final token isToken = “is”;

final token andToken = “and”;

token Comment = “/” ^(“\r” “\n”)*;
interleave TokensIHate = Comment ” ” “\r” “\n”;

final token SearchToken = “Search”;

final token WhereToken = “Where”;




Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s