Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

The Microsoft code name "M" Modeling Language Specification - Languages

November 2009

[This content is no longer valid. For the latest information on "M", "Quadrant", SQL Server Modeling Services, and the Repository, see the  Model Citizen blog.]

 [This documentation targets the Microsoft SQL Server Modeling CTP (November 2009) and is subject to change in future releases. Blank topics are included as placeholders.]

Sections:
1: Introduction to "M"
2: Lexical Structure
3: Text Pattern Expressions
4: Productions
5: Rules
6: Languages
7: Types
8: Computed and Stored Values
9: Expressions
10: Module
11: Attributes
12: Catalog
13: Standard Library
14: Glossary

6 Languages

A language is a named collection of rules for imposing structure on text. 

syntax LanguageDeclaration

    = Attributes? "language" Name LanguageBody;

syntax LanguageBody

    = "{" RuleDeclarations? "}";

syntax RuleDeclarations

    = RuleDeclaration

    | RuleDeclarations RuleDeclaration;

The language that follows recognizes the single text value "Hello World":

module HelloWorld {

    language HelloWorld {

        syntax Main

          = "Hello World";

    }

}

6.1 Main Rule

A language may consist of any number of rules. The following language recognizes the single text value "Hello World":

module HelloWorld {

    language HelloWorld {

        syntax Main

          = Hello Whitespace World;

        token Hello

          = "Hello";

        token World

          = "World";

        token Whitespace

          = " ";

    }

}

The three rules Hello, World, and Whitespace recognize the three single text values "Hello", "World", and " " respectively. The rule Main combines these three rules in sequence. The difference between syntax and token rules is described in §5.1.

Main is the distinguished start rule for a language. A language recognizes a text value if and only if Main recognizes a value. Also, the output for Main is the output for the language.

6.2 Cross-language rule references

Rules are members of a language. A language can use rules defined in another language using member access notation. The HelloWorld language recognizes the single text value "Hello World" using rules defined in the Words language:

module HelloWorld {

       

    language Words {

        token Hello

          = "Hello";

        token World

          = "World";

    }

    language HelloWorld {

        syntax Main

          = Words.Hello Whitespace Words.World;

        token Whitespace =

          = " ";

    }

}

All rules defined within the same module are accessible in this way. Rules defined in other modules must be exported and imported as defined in §10.3.

Show:
© 2015 Microsoft