# MontiCore - Expression-Language Modules

MC-Expressions are used to formulate mathematical and programmatic expressions of a set of literals. To achieve this, a system of modular and pluggable grammar parts are developed.

### Given Expression languages in MontiCore

Currently, there are six expression languages. These are

- ExpressionsBasis (basis for all of the expression languages, supports names and literals)
- AssignmentExpressions (extends ExpressionsBasis, basic assignments)
- CommonExpressions (extends ExpressionsBasis, common expressions like + and -)
- BitExpressions (extends ExpressionsBasis, bit expressions like & or <<)
- LambdaExpressions (extends ExpressionBasis, lambda expressions like a -> a + 2)
- JavaClassExpressions (extends CommonExpressions, adds Java expressions like new)

Two further expression languages are defined in the OCL project:

- OCL-SetExpressions (extends ExpressionsBasis, ideal for working with sets)
- OCL-OCLExpressions (extends ExpressionsBasis, introduces OCL to MontiCore)

Furthermore, composite SI unit expressions are defined in the SI Units project:

- SI Units (can be used to parse primitive units as well as their products, quotients, and powers)

And upcoming, Stream expressions are defined in the SpesML project:

- todo: add lingk to Stream expressions

### Using Expressions

If you want to use one (or more) of the given expression languages in your language, then all you have to do is extend it (or them) in your grammar. You are free to use any of them now.

### Creating your own Expression language

There are some expressions you need desperately and that are not covered
in the given expression languages?

Create a new grammar that extends at least ExpressionsBasis. In this
grammar, you can add your own expressions. These expressions must implement
the interface Expression in the ExpressionsBasis grammar.
To include these expressions in your language, just extend the new grammar in your language.
See here
for an example.