IgorShare Weblog

Practical Engineering

Archive for the ‘Oslo’ Category

Oslo: Basic M grammar for a generic Language

Posted by igormoochnick on 03/23/2009

I’ve noticed that each time when I need to create yet another language definition or some rules grammar, I write the same (or a very similar) “prelude”. I guess that you do the same thing. To simplify the process I’ve crystallized this basis into a simple module. It contains the definition of a Whitespaces, Single- and Multi-line comments and a commands list. You can reuse this module by importing it into your language definition.

Here is the example of a very simple language:

// This is a comment

This_is_some_command;
This_is_another_command;

/* This is a multi-
line comment */

This_is_the_last_command;

The grammar is pretty trivial (if you reuse the foundation grammar – note the import in the beginning):

module SomeLanguageModule
{
    import LanguageBaseModule { Common as C };

    @{CaseInsensitive}
    language RulesDefinition
    {
        // Delimiters
        @{Classification["Delimiter"]}
        token commandDelimiter = ";";

        token Command = c:(C.AlphaNum | "_")+;
       

        // The Program
        syntax Main
            = C.CommandList(Command, commandDelimiter);

        // Ignore whitespace
        interleave Whitespace = C.Whitespace | C.Comment | C.MultiLineComment;
    }
}

The middle section of the grammar  (Command) is where you concentrate your development efforts. Make sure to replace the Command “token” with Command “syntax”.

The Tree result from this grammar and the sample, shown at the top of this post, looks like this:

Main[
  [
    "This_is_some_command",
    "This_is_another_command",
    "This_is_the_last_command"
  ]
]

Download the sample language and the grammar from my SkyDrive.

See the LanguageBaseModule grammar after the break …

Read the rest of this entry »

Posted in M, Oslo | Leave a Comment »

New Oslo bits are out – January CTP

Posted by igormoochnick on 02/03/2009

Yesterday got new Oslo bits (January CTP) – the upgrade went surprisingly smooth. Now I’m hands deep in this new pile of bits. Giving the credit that it’s still CTP – I like the progress so far. Can’t wait to see the release version.

Posted in M, Oslo | Leave a Comment »

IntelliPad (Oslo) switch to interactive mode

Posted by igormoochnick on 12/04/2008

For those who were asking: in order to switch the IntelliPad (Oslo) to interactive mode (MrEPL: REPL for M) follow these steps -

  • Once in Intellipad (with Samples) type “Ctrl-/” to get to the minibuffer.
  • Type: SetMode(‘MScriptMode’)

Posted in M, Oslo | 1 Comment »

Oslo CTP is still pretty rough

Posted by igormoochnick on 10/31/2008

Just noted a funny bug (hint: check the menu):

clip_image001

Posted in Oslo, Thoughts | 4 Comments »