.NET Framework Bookmark and Share   
 index > Microsoft Codename 'Oslo' > DSL for writting Rules
 

DSL for writting Rules

Hello,

My goal is to come up with a domain specific language just for purpose of writting Rules. This is what I am doing and please suggest if there are better ways to handle this scenario

1) I will use OSLO to define my language and convert user inputs in to expected input.

e.g. Syntax for my language will be something similar to

conditional Keyword + operand + operator + operand
if 30 is equal to 30 [Simple]
i have such grammer figured out for all kind of sensense i want to entertain....e.g. Conditional Statement [as mentioend above], assignment statement , looping constructs etc...

2) I will then convert the compiled set of instructions in to the Rule XML so that i can use MS rule engine to execute Rules. I want to bank on MS to execute Rule and wish MS will take all the pain to make it work properly.

I have this simple story to tell with followng caveats.

So i have a fixed my way to writting Rule and will use oslo to validate the same and convert them in to simple set of instructions which then can be converted in to CodeDOM [ or i may convert them in to CodeDOM without requiring intermediate pass]

now i want users to tweak this the way they want...

User can construct conditional statement like
Operand + Operator + operand + conditional key -> "30 is equal to 30 if" and user can define their own keys to do that e.g. they can repace "if" with a different language syntax or some other key word and all...

Is there a way to prompt user write a sentense in a desired way? User will not know that he has goofed up something untill we give the whole string to oslo to validate...

in other words i am looking for intellisense that i can plug and play while writting rule that works for my language only... right now i am managing it runtime by drawing list box to cursoron the editor and showing selectable options and all but it s pain process where user can define their syntax and all... do we have something MS has built for this?

Also can you pelase comment on the approach i am taking to write a Rule with DSL?

thanks
Ammit






Ammit Eclipsys
Ammit--I'm delighted to see this conversation you're having here, and I strongly encourage you to follow Matthew's suggestion to submit any and all suggestions like these through the Connect site. This gets those suggestions and feature requests to the product team directly as potential work items, and gets you in touch with the right people to hash out the details. Posts here on the forum, on the other hand, are very informal and only generate work items if a product team member does that step manually, which isn't often!

And yes, "Oslo" is still very much evolving. Our purpose in putting the technology out in CTP form--which has been done as earlier in any product cycle as I know--is specifically to get the kind of feedback you're offering here. Priorities and requirements are still changing and being clarified, so there's still plenty of time for things to move in directions that you need.

In short, we've put "Oslo" out early on so we can hear from developers what they're really needing. After all, this is a technology for developers and we want to make sure it serves your needs, so communicating those needs to us is very highly appreciated.

Thanks for your input--

.Kraig
Kraig Brockschmidt
Hi Ammit,

In general, your approach seems sound.

You asked "Is there a way to prompt user write a sentense in a desired way? User will not know that he has goofed up something untill we give the whole string to oslo to validate..."

If you don't mind your users using Intellipad as their data (code) entry tool, you should be able to configure an Intellipad mode for your rule language, and the users could use that to interactively validate their input (as it provides the red squiggle underlines and textual error messages for input that fails to be recognized).

If you don't want them to use Intellipad (and you want to create your own editor: a data entry UI), I recommend adding a feature suggestion to Oslo's Connect site, requesting a tool that automatically generates a "language services" class (which could be used in a syntax-directed editor). Such a feature would need design work to figure out how users could cleanly and elegantly encode the heuristics of the responses to the input, and of course it would vary on how user-configurable it would be (whether any keyboard shortcuts are hardcoded or user-configurable, how the various symbol tables and type systems are configured, and at what phases in the parsing and parse-error-recovery...).

I'll be glad to post the suggestion if you like; just let me know!

The other (larger) question you mention is the possibility of letting users define what are essentially "macros" directly in the user's input buffer. This is a much trickier proposition, as it involves the idea of multi-phase parsing/processing (and possibly also compilation/evaluation). Another way to look at it is that you want your users to be able to modify the input language's grammar in the input itself, which is still another order higher than even macros.

Personally, I don't know of a simple way to support such dynamism in the MGrammar system, though you could build your own re-entrant parsing system, where you're constructing and compiling your MGrammar grammars on the fly, and feeding substrings of the input text to the proper custom grammars as you go... but, this would be quite an undertaking (and accomplishment!). :)

Anyone: of course please correct me if these facilities already exist and/or if this is bad advice...

Thank you,
Matthew
'blog: http://diakopter.blogspot.com/ JSMeta: http://jsmeta.org/
Matthew Wilson _diakopter_

Hi Matthew,

Thanks for your prompt reply.

I think OSLO is still evolving. Its better if MSFT look at such suggestions and build something around it. As per my understanding if someone is building DSL he wants to do one of two things...
1) Inject inline logic [ may be conditional/assignment instruction execution]
2) Convert Client in to Coder. Frankly, no matter how detailed requirements you collect each customer is treating one or more things differently. Instead of releasing HOT FIXES and SPs just to tweak a few instructions is not logical. My idea is rather to convert customer in to coder and let them contribute to the system. Initially i was having only hands ful of people to write code and now my whole customer base will turn in to coder. That is what i really want to achieve.

Now, I got Intellipad and the editor is nice but it’s not at all user friendly. In other words it does show error but does not show intellisense [please let me know if they can show intellisense i will stop building my own]. So coming back to original idea. Now customer has to remember all the Property of a particular class while writing Rule which is quite impossible unless we present them with Intellisense. I am striving for intellisense. please let me know if we have one with OSLO or any other MS Editor kind of tool.

Not everyone would like to write the rule the way i dictate so i want to give them liberty of changing language construct within my boundary. As per my example I want them to change the order of operator and operand etc... or they can even change the Key Words e.g. "IF" can be mapped to "OF", "IS" can be mapped to "==" and all. I think by giving such features i can turn more clients in to coders. I agree with your suggestion and in fact that is what i am doing right now. We do a lot of munching inmemory and convert customer syntax in to "SYSTEM" syntax before giving it to OSLO. That has solved the problem for me for now. Building MGrammer on the fly sounds a bit risky to me. I am also building grammar andsyntax dictionary so you can now import the dictionary you want to use for writting your Instructions. Editor is a dumb fellow and will show intellisense mentioned in the Grammar.

by now we have already built a quite Editor to show intellisense and almost everything i talked about in elementary stage.
I am really open for suggestions and inputs...

Thanks
Ammit

Ammit Eclipsys
Ammit--I'm delighted to see this conversation you're having here, and I strongly encourage you to follow Matthew's suggestion to submit any and all suggestions like these through the Connect site. This gets those suggestions and feature requests to the product team directly as potential work items, and gets you in touch with the right people to hash out the details. Posts here on the forum, on the other hand, are very informal and only generate work items if a product team member does that step manually, which isn't often!

And yes, "Oslo" is still very much evolving. Our purpose in putting the technology out in CTP form--which has been done as earlier in any product cycle as I know--is specifically to get the kind of feedback you're offering here. Priorities and requirements are still changing and being clarified, so there's still plenty of time for things to move in directions that you need.

In short, we've put "Oslo" out early on so we can hear from developers what they're really needing. After all, this is a technology for developers and we want to make sure it serves your needs, so communicating those needs to us is very highly appreciated.

Thanks for your input--

.Kraig
Kraig Brockschmidt
Sounds like you have already made progress on your own editor but wanted to mention a 3rd party who has released a beta of their WPF Editor Control that supports MGrammar. You can find more info about it here:

http://blog.actiprosoftware.com/post/2009/06/02/Integrating-MGrammar-DSL-parsers-with-SyntaxEditor-to-implement-syntax-highlighting.aspx

D Kaufman

Hi

Thanks for your input.
I will look in to this. But by now we are so sold on the idea i meantioned above.

Kraig thanks for your input. I have already posted a suggestion on OSLO and hopeful to heard something back from MSFT soon on this.

I am really banking a lot on this and hope things sail smooth for me.

thank everyone for their participation. We can close this thread now.

thanks

Ammit

Ammit Eclipsys
Ceyhun Ciper

You can use google to search for other answers

Custom Search

More Threads

• Why don't you build a Grammar Repository?
• Is the IntelliPad Team Blog inactive?
• On releasing "M" language specification under the OSP
• Intellisense for Intellipad
• Intellipad won't start!
• Is using Oslo in BI applications a good idea?
• M CodeDom equivalent...?
• GraphBuilder internal inner types
• Getting data in and out of the repository, using the "Oslo" way
• Oslo and New SQL 2008 Types