-
Notifications
You must be signed in to change notification settings - Fork 0
2 Types
Studio 42 GmbH edited this page Dec 27, 2022
·
1 revision
Types allow to define the allowed entities in your domain dialect. They provide a flexible hierarchical system. Type names have to be unique. Simple types represent a data type like String, UUID, .... Complex types represent class/struct-like data. Types can easily be extended (See https://github.com/studio42gmbh/dl/tree/master/src/main/java/de/s42/dl/types)
EXTERN TYPE name;
( FINAL | ABSTRACT )? TYPE name @annotation*
( EXTENDS parent (, parent )* )?
( CONTAINS contained (, contained )* )?
{
type ( < type (, type)* > )? name @annotation* ( : ("default" | instance | $reference ))? ;
REQUIRE moduleId;
}
Here is excerpt of the parser definition in ANTLR4 grammar:
typeDefinition :
( KEYWORD_EXTERN | KEYWORD_FINAL | KEYWORD_ABSTRACT )?
KEYWORD_TYPE
typeDefinitionName
annotation*
( KEYWORD_EXTENDS parentTypeName ( COMMA parentTypeName )* )?
( KEYWORD_CONTAINS containsTypeName ( COMMA containsTypeName )* )?
( typeBody | SEMI_COLON ) ;
typeDefinitionName : identifier;
parentTypeName : identifier ;
containsTypeName : identifier ;
typeBody : SCOPE_OPEN ( typeAttributeDefinition | require )* SCOPE_CLOSE ;
typeAttributeDefinition :
typeAttributeDefinitionType
typeAttributeDefinitionName
annotation*
( COLON typeAttributeDefinitionDefault )?
SEMI_COLON ;
typeAttributeDefinitionType : typeIdentifier genericParameters? ;
typeAttributeDefinitionName : identifier ;
typeAttributeDefinitionDefault : instanceDefinition | STRING_LITERAL | FLOAT_LITERAL | INTEGER_LITERAL | BOOLEAN_LITERAL | SYMBOL | REF ;
extern type de.s42.dl.types.ObjectDLType;
final type Achievement @dynamic extends Object
{
Symbol hrid @required @length(3, 100) @unique;
UUID id @generateUUID @required;
}
type User @dynamic @contain(Media, 0, 100) extends Object contains Media
{
String login @required @length(3, 100) @unique;
UUID id @generateUUID @required;
boolean active : true;
MemberStatus status : Guest;
Array<Achievement> achievements;
}
Copyright Studio 42 GmbH 2022.