
Contents |
This is a collection of language descriptions. For each language, there are defined the abstract syntax and one concrete syntax. The abstract syntax definition language is oriented at the one used in [Mey90]. In the language, there are four kinds of grammar rules:
is a rule that is an aggregation of references to other rules. It corresponds to the definition of references in a metamodel.
is a rule defining a set of alternatives. It corresponds to the subclass-of relationship in a metamodel where all subclasses (i.e., alternatives) can substitute their superclass.
defines that a rule inherits all properties from a super-rule. It also corresponds to the subclass-of relationship in a metamodel. Here, it expresses that a subclass inherits all references from its superclass. Such expressiveness is usually not supported by grammar languages and only available in metamodels. Note that the rules super-rule = alternative-rule ";" and alternative rule ==> super rule ";" technically express the same thing. The distinction exists to express the different usages of subclass-of in distinct ways, which enhances readability.
Empty rules (i.e., classes without references) act as terminal symbols. A special case is the terminal rule S, which is predefined. It denotes the infinite set of strings and is mapped to an attribute of the primitive type String in metamodels.
It is possible to refer to rules defined in other grammars to extend an existing language:
The concrete syntax definition language is used to write concrete syntax grammars for a previously defined abstract syntax. For one abstract syntax, different concrete syntaxes may exist. Composition works solely on the abstract syntax. Thus, fragments written in different concrete syntaxes can be composed. A concrete syntax grammar has a header line and rules oriented at EBNF rules [Int96].
defines for which abstract syntax this concrete syntax is defined.
The rule name corresponds to the name of an aggregation rule in the abstract syntax. The rule can contain nested sequences and alternatives of elements. An element is either part of the concrete syntax, of a concrete string encapsulated in quote symbols (" or ’), or of a reference defined in the abstract syntax. References that have a multiplicity greater than one may be used several times in a concrete syntax definition. They will be merged to one reference in the abstract syntax tree.
Note that a concrete syntax has to be defined for each abstract syntax aggregation rule. This includes referenced rules defined in other abstract syntax grammars. In cases where a concrete syntax for such rules should be reused (e.g., in a reuse language) a simple mechanism to extend concrete syntax grammars is provided.
All the definitions that exist in the super-grammar are imported but may be overridden.
Abstract syntax grammar
AbstractSyntax = rules:Rule+; Rule = name:Identifier, definition:Definition?; Identifier = identifier:S; Definition = Aggregation | Choice; Choice = options:Identifier+; Aggregation = reference:Reference+; Reference = name:Identifier, rule:Identifier, cardinality:Cardinality?; Cardinality = PLUS | STAR | QUESTIONMARK; PLUS; STAR; QUESTIONMARK;
Concrete syntax grammar
CONCRETESYNTAX as FOR abstractsyntax
AbstractSyntax ::= rules+;
Rule ::= (name ("=" definition)? ";") | (definition "==>" name ";");
Identifier ::= identifier[((’A’..’Z’|’a’..’z’|’0’..’9’)+ ’.’)?(’A’..’Z’|’a’..’z’|’0’..’9’)+];
Choice ::= options ( "|" options)* ;
Aggregation ::= reference ( "," reference )*;
Reference ::= (name ":" rule cardinality?) ;
PLUS ::= "+";
STAR ::= "*";
QUESTIONMARK ::= "?";
Abstract syntax grammar
ConcreteSyntax = name:S, languageName:S, superGrammar:S?, rules:Rule+; Rule = name:Metaidentifier, definition:Choice; Metaidentifier = identifier:S; Choice = options:Aggregation+; Aggregation = parts:SingleDefinition+; SingleDefinition = body:DefinitionBody, cardinality:Cardinality?; DefinitionBody = SubDefinition | Reference | CsString; SubDefinition = definition:Choice; Reference = name:S, regex:S?; CsString = value:S; Cardinality = PLUS | STAR | QUESTIONMARK; PLUS; STAR; QUESTIONMARK;
Concrete syntax grammar
CONCRETESYNTAX cs FOR concretesyntax
ConcreteSyntax ::= "EBNF" name[((’A’..’Z’|’a’..’z’|’0’..’9’)+ ’.’ )?(’A’..’Z’|’a’..’z’|’0’..’9’)+]
"FOR" languageName[((’A’..’Z’|’a’..’z’|’0’..’9’)+ ’.’ )?
(’A’..’Z’|’a’..’z’|’0’..’9’)+]
"EXTENDS" superGrammar[((’A’..’Z’|’a’..’z’|’0’..’9’)+ ’.’ )?
(’A’..’Z’|’a’..’z’|’0’..’9’)+])? rules+;
Rule ::= name "::=" definition ";";
Metaidentifier ::= identifier[((’A’..’Z’|’a’..’z’|’0’..’9’)+ ’.’ )?
(’A’..’Z’|’a’..’z’|’0’..’9’)+];
Aggregation ::= parts+;
Choice ::= options ("|" options)*;
SingleDefinition ::= body cardinality?;
Reference ::= name[((’A’..’Z’|’a’..’z’|’0’..’9’)+ ’.’ )? (’A’..’Z’|’a’..’z’|’0’..’9’)+]
regex[’[’ ( ’ ’|’(’|’)’|’|’|’?’|’*’|’+’|’~’|’.’|
(’\’’ ( ~(’\’’|’\\’) | (’\\’ .))* ) ’\’’ )* ’]’]?;
CsString ::= value[(’\"’ (~’\"’)* ’\"’) | (’\’’ (~’\’’)* ’\’’)];
SubDefinition ::= "(" definition ")";
PLUS ::= "+";
STAR ::= "*";
QUESTIONMARK ::= "?";