Commit c5e10116 authored by Philip Makedonski's avatar Philip Makedonski
Browse files

+ added initial support for enums and constraints (syntax tbc)

* refined braces to enable permanent braces (also in indentation-based syntax)
parent 47750b5b
Loading
Loading
Loading
Loading
+72 −6
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ Package returns tdl::Package:

PackageableElement returns tdl::PackageableElement:
    AnnotationType | TestObjective
     | ConstraintType
     | DataResourceMapping | DataElementMapping
     | SimpleDataType_Impl | SimpleDataInstance 
     | StructuredDataType | StructuredDataInstance 
@@ -35,6 +36,7 @@ PackageableElement returns tdl::PackageableElement:
     | ProcedureSignature 
     | Action_Impl | Function 
     | PredefinedFunction 
     | EnumDataType
     | Time 
     | ComponentType | GateType 
     | TestConfiguration 
@@ -111,6 +113,21 @@ Extension returns tdl::Extension:
    //WithCommentFragment?
;

ConstraintType returns tdl::ConstraintType: 
    //PrefixFragment?
    'Constraint'
    name=Identifier
    //WithCommentFragment?
;

Constraint returns tdl::Constraint: 
    //PrefixFragment?
    type=[tdl::ConstraintType|Identifier]
    (':' quantifier+=LiteralValueUse (',' quantifier+=LiteralValueUse)+ )?
    //WithCommentFragment?
;


//# Data

//## Data Definition
@@ -151,6 +168,7 @@ SimpleDataType_Impl returns tdl::SimpleDataType:
    {tdl::SimpleDataType}
    PrefixFragment?
    'Type'
    ConstraintFragment?
    name=Identifier
    WithCommentFragment?
;
@@ -167,6 +185,8 @@ StructuredDataType returns tdl::StructuredDataType:
    {tdl::StructuredDataType}
    PrefixFragment?
    'Type'
    //TODO: reconsider order (conflicts, also for other types)
    ConstraintFragment?
    name=Identifier
    extension=Extension?
    BEGIN
@@ -177,6 +197,7 @@ StructuredDataType returns tdl::StructuredDataType:

Member returns tdl::Member:
    PrefixFragment?
    MemberConstraintFragment?
    (isOptional?='optional')?
    dataType=[tdl::DataType|Identifier]
    name=Identifier
@@ -214,6 +235,7 @@ CollectionDataType returns tdl::CollectionDataType:
    PrefixFragment?
    'Collection'
    name=Identifier
    ConstraintFragment?
    'of' itemType=[tdl::DataType|Identifier]
    //TODO: use angle brackets instead of 'of'?
    WithCommentFragment?
@@ -318,6 +340,17 @@ PredefinedIdentifierSize returns ecore::EString:
    'size'
;

EnumDataType returns tdl::EnumDataType: 
    //PrefixFragment?
    'Enumerated'
    name=Identifier
    BEGIN
        //TODO: without type specification?
        (value+=SimpleDataInstance)+
    END
    //WithCommentFragment?
;

//## Data Use

DataUse returns tdl::DataUse:
@@ -351,6 +384,7 @@ CollectionReference returns tdl::MemberReference:
StaticDataUse returns tdl::StaticDataUse:
//    DataInstanceUse
    GenericDataInstanceUse
//    | 'JSON:' JSONDataInstanceUse
    | AnonymousDataInstanceUse 
    | SpecialValueUse
    | LiteralValueUse
@@ -381,6 +415,26 @@ AnonymousDataInstanceUse returns tdl::DataInstanceUse:
    ParameterBindingFragment
;

//TODO: Explore JSON data further or discard
//JSONDataInstanceUse returns tdl::DataInstanceUse:
//    {tdl::DataInstanceUse}
//    //TODO: add annotation?
//    //TODO: add collections?
//    //TODO: persist with indentation?
//    RBegin
//    argument+=JSONParameterBinding ( "," argument+=JSONParameterBinding)*
//    REnd
//;
//
//JSONParameterBinding returns tdl::ParameterBinding:
//    //PrefixFragment?
//    parameter=[tdl::Parameter|EString]
//    ':' (dataUse=LiteralValueUse | dataUse=JSONDataInstanceUse)
//    //TODO: this is ambiguous    
//    //WithNameFragment?
//;


//TODO: Problematic
//DataInstanceUse returns tdl::DataInstanceUse:
//    {tdl::DataInstanceUse}
@@ -1178,6 +1232,14 @@ fragment PrefixFragment returns tdl::Element:
    ('@' annotation+=Annotation)+
;

fragment ConstraintFragment returns tdl::DataType:
    LBrace (constraint+=Constraint)+ RBrace
;

fragment MemberConstraintFragment returns tdl::Member:
    LBrace (constraint+=Constraint)+ RBrace
;


//fragment PrefixNameFragment returns tdl::Element:
//    '@' NameFragment
@@ -1226,6 +1288,14 @@ QIdentifier returns ecore::EString:
    ID ('.' ID)+
;

//Retain Braces even in indentation-based
LBrace:
    BEGIN
;

RBrace:
    END
;

//## Terminals
    
@@ -1234,9 +1304,5 @@ QIdentifier returns ecore::EString:
//terminal END: 'synthetic:END';      // decrease indentation

//alternative bindings for brace-based delimiters
terminal BEGIN: LBRACE;
terminal END: RBRACE;

//separate terminals that can be used for JSON-like data specifications even in indentation-based notation
terminal LBRACE: '{';
terminal RBRACE: '}';
terminal BEGIN: '{';
terminal END: '}';