Formal grammars in MPS?

I have had only a very quick look through the on-line HelloWorld example so apologies if I have missed something obvious.  

I expected some form of formal grammar (e.g. BNF) to be at the heart of this framework but didn't notice anything like that in the tutorial. I am currently writing a functrional language and would be very interested in any pointers that detail MPS's parsing methods.

Philip

3 comments
Comment actions Permalink

Philip Milne wrote:

I have had only a very quick look through the on-line HelloWorld example so apologies if I have missed something obvious.  

I expected some form of formal grammar (e.g. BNF) to be at the heart of this framework but didn't notice anything like that in the tutorial. I am currently writing a functrional language and would be very interested in any pointers that detail MPS's parsing methods.

Structure language in MPS plays the same role as grammar. Approach used

in MPS more closer to OOP than to grammars.

For example if you want to write such grammar as

Expression :

     Number

   | Expression + Expression

   | Expression - Expression

You have to create abstract concept Expression. Derive from it concepts

for PlusExpression, MinusExpression, NumberExpression.

0
Comment actions Permalink

Thanks for the reply Konstantin. Ah OK, I see what you mean.

Still, wouldn't it would be nice to have, um, a domain specific language for this? I've been a long-time fan of pretty much everything you guys have done so I am reluctant to criticise but the thought of inputting the grammar for a large language (like, say, Java 1.0) term by term through a GUI makes me feel a bit queasy. If it's just data, I wonder if it would be worth thinking about having a meta language (something like BNF with extras) as an alternative format for persisting DSLs in MPS.

I guess what I'm really thinking of is that there are a lot of languages out there for which grammars have already been written. Ever the optimist, I'm tempted to think that a bit of ad-hoc textual manipulation might get them to a format you propose. If so, that might be a good way to at least get some useful primitive editing functions up and running quickly with new languages. I'm thinking of simple things like syntax highlighting, first-pass syntax checking, maybe even brace matching (important to us functional types).

Just a thought - by all means ignore it - meanwhile I'll take a closer look at what you have!  

0
Comment actions Permalink

I apologize to all for the off-topic.  Philip, I could not find your

email from the forums, please email me at beg at jetbrains.com.

Eugene Belyaev

President

JetBrains

http://www.jetbrains.com

"Develop with pleasure!"

Philip Milne wrote:

I have had only a very quick look through the on-line HelloWorld example so apologies if I have missed something obvious.  

I expected some form of formal grammar (e.g. BNF) to be at the heart of this framework but didn't notice anything like that in the tutorial. I am currently writing a functrional language and would be very interested in any pointers that detail MPS's parsing methods.

Philip

0

Please sign in to leave a comment.