Monday, August 23, 2010

"M" language, Modeling in Text

This five-part video series by Miguel Llopis, a member of the “M” language team, leads you through the step-by-step process of modeling a basic domain-specific language.

Level: 300 (core competency)

My Notes: easy video, fast intro to the M-language.

Samples show how to convert

Pat is 24 years old.
Chris is 32 years old.
Granny is 98 years old.
Billy is 3 years old.

To this:

Main[
[
{
Name => "Pat",
Age => "24"
},
{
Name => "Chris",
Age => "32"
},
{
Name => "Granny",
Age => "98"
},
{
Name => "Billy",
Age => "3"
}
]
]

Using this grammar:

module NovCTP {
language Contacts {
syntax Main = p:Person*
=> People { valuesof(p) };
syntax Person = n:Name "is" a:Age "years" "old."
=> { Name => n, Age => a};
token Name = ('a'..'z' | 'A'..'Z')+;
token Age = '0'..'9'+;
interleave Whitespace = " " | "\r" | "\n";
}
}



No comments: