Commit 859d437f authored by Philip Makedonski's avatar Philip Makedonski
Browse files

+ added behaviours, static data uses (WIP, open issues)

parent 18bc3c11
Loading
Loading
Loading
Loading
+335 −75
Original line number Diff line number Diff line
@@ -65,7 +65,10 @@ ElementImport returns tdl::ElementImport:
            ( "," importedElement+=[tdl::PackageableElement|Identifier])*
        )
    )
    'from' (importedPackage=[tdl::Package|Identifier] | importedPackage=[tdl::Package|QIdentifier])
    'from' 
        (importedPackage=[tdl::Package|Identifier]
       | importedPackage=[tdl::Package|QIdentifier]
    )
    WithCommentFragment?
;

@@ -185,10 +188,10 @@ StructuredDataInstance returns tdl::StructuredDataInstance:
    PrefixFragment?
    dataType=[tdl::DataType|Identifier]
    name=Identifier
    //TODO: use keywords?
    //TODO: use keywords for unassigned member treatment?
    (unassignedMember=UnassignedMemberTreatment)?
    BEGIN
        //TODO: use parentheses instead? (structure vs parameters)
        //TODO: use parentheses instead? (structure vs parameters), also for type above
        //TODO: disambiguate when indentation is used?
        //TODO: align with data use
        (memberAssignment+=MemberAssignment)*
@@ -219,9 +222,7 @@ CollectionDataType returns tdl::CollectionDataType:

CollectionDataInstance returns tdl::CollectionDataInstance:
    PrefixFragment?
    //TODO: keep square brackets? ->discuss later (exclusive to guards or guards shall use a word?)
    dataType=[tdl::DataType|Identifier] //-> should probably be preferred for index or also for begin/end below
    //alternatively dataType 'collection' name? -> no
    dataType=[tdl::DataType|Identifier] 
    name=Identifier
    '[' item+=StaticDataUse* ']'
    WithCommentFragment?
@@ -308,20 +309,148 @@ PredefinedFunction returns tdl::PredefinedFunction:

//TODO: continue with data use...

DataUse returns tdl::DataUse:
    StaticDataUse | DynamicDataUse
;

ParameterBinding returns tdl::ParameterBinding:
    //PrefixFragment?
    parameter=[tdl::Parameter|Identifier]
    '=' dataUse=DataUse
    //TODO: this is ambiguous    
    //WithNameFragment?
;

MemberReference returns tdl::MemberReference:
    {tdl::MemberReference}
    //PrefixFragment?
    member=[tdl::Member|Identifier] 
    //('[' collectionIndex=DataUse ']')? 
    //TODO: this is ambiguous    
    //WithNameFragment?
;

//TODO: Synthetic
CollectionReference returns tdl::MemberReference:
    //PrefixFragment?
    '[' collectionIndex=DataUse ']'
    //TODO: this is ambiguous    
    //WithNameFragment?
;

StaticDataUse returns tdl::StaticDataUse:
    OmitValue //| AnyValue | AnyValueOrOmit | DataInstanceUse | LiteralValueUse
    DataInstanceUse 
    | SpecialValueUse
    | LiteralValueUse
;

DataInstanceUse returns tdl::DataInstanceUse:
    {tdl::DataInstanceUse}
    //PrefixFragment?
    (
        ReferencedDataInstance
//        | AnonymousDataInstanceWithType
           //TODO: some ambiguity with UnassignedMemberTreatment
//        | AnonymousDataInstanceWithoutType
//        | AnonymousCollection
    ) 
    //TODO: this is ambiguous    
    //WithNameFragment?
;

fragment ParameterBindingFragment returns tdl::DataInstanceUse:
    ('(' argument+=ParameterBinding ( "," argument+=ParameterBinding)* ')' )
;

fragment UnassignedFragment returns tdl::DataInstanceUse:
    //TODO: added angle brackets for disambiguation
    '<' unassignedMember=UnassignedMemberTreatment '>'
;

fragment ReferencedDataInstance returns tdl::DataInstanceUse:
    //referenced DataInstance, arguments or reduction optional
    dataInstance=[tdl::DataInstance|Identifier]
    UnassignedFragment?
    (
        ParameterBindingFragment
        //TODO: reduction problematic
//        |
//        (   (reduction+=CollectionReference)?
//            ('.' reduction+=MemberReference)*
//        )
    )?
;

fragment AnonymousDataInstanceWithType returns tdl::DataInstanceUse:
    //anonymous with data type, arguments mandatory, only structured data types
    ('a' dataType=[tdl::StructuredDataType|Identifier])?
    UnassignedFragment?
    ParameterBindingFragment
;

fragment AnonymousDataInstanceWithoutType returns tdl::DataInstanceUse:
    //anonymous with no data type, arguments mandatory, otherwise AnyValue, only structured data types
    //type assumed from context
    //TODO: ambiguity -> placehodler keyword?
    UnassignedFragment?
    ParameterBindingFragment
;

fragment AnonymousCollection returns tdl::DataInstanceUse:
    //TODO: Not standardised: inline collections, no type needed? (only when used in interaction?)
    ('a' dataType=[tdl::CollectionDataType|Identifier])?
    UnassignedFragment?
    //TODO: Only static?
    '[' (item+=StaticDataUse ("," item+=StaticDataUse)*)? ']'
;


SpecialValueUse returns tdl::SpecialValueUse:
    OmitValue | AnyValue | AnyValueOrOmit 
;

AnyValue returns tdl::AnyValue:
    {tdl::AnyValue}
    PrefixFragment?
    name='?'
    //TODO: use 'of' keyword or 'of type'?
    (':' dataType=[tdl::DataType|Identifier])?
    //TODO: this is ambiguous    
    //WithCommentFragment?
;

AnyValueOrOmit returns tdl::OmitValue:
    {tdl::OmitValue}
    PrefixFragment?
    name='*'
    //TODO: this is ambiguous    
    //WithCommentFragment?
;

OmitValue returns tdl::OmitValue:
    {tdl::OmitValue}
    PrefixFragment?
    'omit'
    name='omit'
    //TODO: this is ambiguous    
    //WithCommentFragment?
;


DynamicDataUse returns tdl::DynamicDataUse:
    'todo:dynamic'
//    FormalParameterUse | FunctionCall | VariableUse | TimeLabelUse | PredefinedFunctionCall
;

LiteralValueUse returns tdl::LiteralValueUse:
    {tdl::LiteralValueUse}
    value=LiteralValue
    //TODO: ambiguity if type? value -> temporary solution
    ('of' 'type' dataType=[tdl::DataType|Identifier])?
    //TODO: ambiguity
    //WithNameFragment?
    //Reduction and argument are excluded
;

//# Time

Timer returns tdl::Timer:
@@ -335,7 +464,7 @@ Timer returns tdl::Timer:
TimeConstraint returns tdl::TimeConstraint:
    //TODO: this is ambiguous    
    //PrefixFragment?
    timeConstraintExpression=StaticDataUse //TODO: revert to DataUse
    timeConstraintExpression=DataUse
    //WithCommentFragment?
;

@@ -351,14 +480,8 @@ enum TimeLabelUseKind returns tdl::TimeLabelUseKind:
    Last = 'Last' | Previous = 'Previous' | First = 'First'
;



//TODO: continue with the rest

//# Test Configuration

//TODO: test all and refine

GateType returns tdl::GateType:
    PrefixFragment?
    kind=GateTypeKind
@@ -367,7 +490,6 @@ GateType returns tdl::GateType:
    (extension=Extension)?
    //TODO: revert to 'accepts'
    'supports' dataType+=[tdl::DataType|Identifier] ( "," dataType+=[tdl::DataType|Identifier])*
    //TODO: potential ambiguity?
    WithCommentFragment?  
;

@@ -387,26 +509,21 @@ ComponentType returns tdl::ComponentType:
    'Component'
    name=Identifier
    (extension=Extension)?
    //TODO: align order?
    BEGIN
        (gateInstance+=GateInstance)+ 
        (timer+=Timer)*
        (variable+=Variable)*
        (gateInstance+=GateInstance)* 
    END
    WithCommentFragment?  
;

ComponentInstance returns tdl::ComponentInstance:
    PrefixFragment?
    'create'
    role=ComponentInstanceRole
    type=[tdl::ComponentType|Identifier]
    'component'
    name=Identifier
    'as'
    //TODO: or use annotation syntax? -> no
    //TODO: re-evaluate existing notation -> condense to more compact definition
    //create ROLE TYPE ID
    //create ROLE ID of type TYPE (old notation) -> to be aligned with data type syntax and the rest
    role=ComponentInstanceRole
    //create ROLE TYPE ID vs create ROLE ID of type TYPE (old notation) -> to be aligned with data type syntax and the rest
    WithCommentFragment?  
;

@@ -419,16 +536,14 @@ GateReference returns tdl::GateReference:
    component=[tdl::ComponentInstance|Identifier]
    '.' 
    gate=[tdl::GateInstance|Identifier]
    //WithCommentFragment?
    //TODO: add extended name fragments
    //WithNameFragment?
;

Connection returns tdl::Connection:
    PrefixFragment?
    'connect'
    endPoint+=GateReference 'to' endPoint+=GateReference
    WithCommentFragment?
    //TODO: add extended name fragments
    WithNameFragment?
;


@@ -437,7 +552,6 @@ TestConfiguration returns tdl::TestConfiguration:
    'Configuration'
    name=Identifier
    BEGIN
        //TODO: enforce '+'?
        (componentInstance+=ComponentInstance)* 
        (connection+=Connection)* 
    END
@@ -458,12 +572,16 @@ TestDescription returns tdl::TestDescription:
    (
        behaviourDescription=BehaviourDescription
    )?
    WithCommentFragment?
    //TODO: add extended objective fragments
    //TODO: ambiguity
    //WithTDFragment?
;

BehaviourDescription returns tdl::BehaviourDescription:
    behaviour=Behaviour
    //behaviour=Behaviour
    behaviour=CompoundBehaviour
    //TODO: differentiate between atomic and combined behaviours
    //      embed atomic behaviours in a "block" nonetheless?
    //      or switch to combined behaviour?
    //TODO: fix fragments
//    NameFragment?
//    WithFragmentNested?
@@ -472,89 +590,172 @@ BehaviourDescription returns tdl::BehaviourDescription:
//## Combined Behaviour

Behaviour returns tdl::Behaviour:
    //TimerStart | TimerStop | TimeOut | Wait | Quiescence | PeriodicBehaviour | AlternativeBehaviour | ParallelBehaviour | BoundedLoopBehaviour | OptionalBehaviour | UnboundedLoopBehaviour | ConditionalBehaviour | CompoundBehaviour | DefaultBehaviour | InterruptBehaviour | VerdictAssignment | Assertion | Stop | Break | Assignment | InlineAction | ActionReference | TestDescriptionReference | Interaction_Impl | Message | ProcedureCall;
    TimerStart | TimerStop | TimeOut
    | CompoundBehaviour
    CombinedBehaviour | AtomicBehaviour
    //excluded via constraint:
    //PeriodicBehaviour
    //DefaultBehaviour | InterruptBehaviour | 
;

Block returns tdl::Block:
    //TODO: fragments cause ambiguity
    //PrefixFragment?
    //PrefixNameFragment?
    //TODO: extract to fragment
    //TODO: shall guards use a keyword instead?
    ('[' guard+=LocalExpression ( "," guard+=LocalExpression)* ']' )?
    BEGIN
        behaviour+=Behaviour+ 
    END
    //WithNameFragment?
;

LocalExpression returns tdl::LocalExpression:
    //TODO: this is ambiguous    
    //PrefixFragment?
    (scope=[tdl::ComponentInstance|Identifier] ':')?
    expression=StaticDataUse //TODO: revert to DataUse
    //WithCommentFragment?
    //TODO: add extended name fragments
    expression=DataUse
    //WithNameFragment?
;

CombinedBehaviour returns tdl::CombinedBehaviour:
    SingleCombinedBehaviour | MultipleCombinedBehaviour
;

SingleCombinedBehaviour returns tdl::SingleCombinedBehaviour:
    CompoundBehaviour
    | BoundedLoopBehaviour
    | UnboundedLoopBehaviour 
    | OptionalBehaviour
;

CompoundBehaviour returns tdl::CompoundBehaviour:
    //TODO: ambiguity
    //PrefixFragment?
    block=Block
    WithCombinedFragment?
;

BoundedLoopBehaviour returns tdl::BoundedLoopBehaviour:
    PrefixFragment?
    'repeat'
    numIteration+=LocalExpression 'times' (',' numIteration+=LocalExpression 'times')*
    block=Block
    //TODO: extract to fragment
//    PrefixObjectiveFragment?
//    PrefixNameFragment?
    WithCombinedFragment?
;

    //TODO: periodic / exceptional fragments
    //('periodic' '{' periodic+=PeriodicBehaviour ( "," periodic+=PeriodicBehaviour)* '}' )?
    //('exceptional' '{' exceptional+=ExceptionalBehaviour ( "," exceptional+=ExceptionalBehaviour)* '}' )?
//    WithCommentFragment?
UnboundedLoopBehaviour returns tdl::UnboundedLoopBehaviour:
    PrefixFragment?
    'repeat'
    block=Block
    WithCombinedFragment?
;

OptionalBehaviour returns tdl::OptionalBehaviour:
    PrefixFragment?
    'optionally'
    block=Block
    WithCombinedFragment?
;

MultipleCombinedBehaviour returns tdl::MultipleCombinedBehaviour:
    ConditionalBehaviour 
    | AlternativeBehaviour
    | ParallelBehaviour
;

ConditionalBehaviour returns tdl::ConditionalBehaviour:
    PrefixFragment?
    'if' block+=Block
    (=>('else' block+=Block)
    | (('else' 'if' block+=Block)* 
       ('else' block+=Block)))? 
    WithCombinedFragment?
;

AlternativeBehaviour returns tdl::AlternativeBehaviour:
    PrefixFragment?
    'alternatively'
    block+=Block
    //TODO: enforce 2+? 
    ('or' block+=Block)* 
    WithCombinedFragment?
;

ParallelBehaviour returns tdl::ParallelBehaviour:
    PrefixFragment?
    'run' block+=Block 
    //TODO: enforce at least 2?
    //TODO: simplify keywords / syntax
    ('in' 'parallel' 'to' block+=Block)?
    ('and' block+=Block)*
    WithCombinedFragment?
;

ExceptionalBehaviour returns tdl::ExceptionalBehaviour:
    DefaultBehaviour | InterruptBehaviour;

DefaultBehaviour returns tdl::DefaultBehaviour:
    PrefixFragment?
    'default'
    //TODO: switch to component: default? (also interrupt)
    ('on' guardedComponent=[tdl::ComponentInstance|Identifier])?
    block=Block
    WithBehaviourFragment?
;

InterruptBehaviour returns tdl::InterruptBehaviour:
    PrefixFragment?
    'interrupt'
    ('on' guardedComponent=[tdl::ComponentInstance|Identifier])?
    block=Block
    WithBehaviourFragment?
;

PeriodicBehaviour returns tdl::PeriodicBehaviour:
    PrefixFragment?
    'every'
    (period+=LocalExpression (',' period+=LocalExpression)*)
    block=Block
    WithBehaviourFragment?
;

//## Atomic Behaviour

AtomicBehaviour returns tdl::AtomicBehaviour:
    TimerStart | TimerStop | TimeOut
    //| Wait | Quiescence | 
    //VerdictAssignment | Assertion
    //| Stop | Break
    //| Assignment 
    //| InlineAction | ActionReference 
    //| TestDescriptionReference 
    //| Interaction_Impl | Message | ProcedureCall;
;

TimerStart returns tdl::TimerStart:
    PrefixFragment?
    //TODO: extract to fragment
//    PrefixObjectiveFragment?
//    PrefixNameFragment?
//    PrefixTimeLabelFragment?
//    PrefixTimeConstraintFragment?
    'start'
    componentInstance=[tdl::ComponentInstance|Identifier]
    '.'
    timer=[tdl::Timer|Identifier]
    'for' period=StaticDataUse
    //TODO: shortcut, restore original
    //'for' period=DataUse
    'for' period=DataUse
    WithAtomicFragment?
;

TimerStop returns tdl::TimerStop:
    PrefixFragment?
    //TODO: extract to fragment
//    PrefixObjectiveFragment?
//    PrefixNameFragment?
//    PrefixTimeLabelFragment?
//    PrefixTimeConstraintFragment?
    'stop'
    componentInstance=[tdl::ComponentInstance|Identifier]
    '.'
    timer=[tdl::Timer|Identifier]
    WithAtomicFragment?
;

TimeOut returns tdl::TimeOut:
    PrefixFragment?
    //TODO: extract to fragment
//    PrefixObjectiveFragment?
//    PrefixNameFragment?
//    PrefixTimeLabelFragment?
//    PrefixTimeConstraintFragment?
    componentInstance=[tdl::ComponentInstance|Identifier]
    '.'
    timer=[tdl::Timer|Identifier]
    'expired'
    WithAtomicFragment?
;


@@ -574,26 +775,79 @@ TimeOut returns tdl::TimeOut:

//Use: inline block - within other blocks, e.g. with other contents 
fragment WithCommentFragment returns tdl::Element:
    ('With:'
    'With:'
    BEGIN
        (comment+=Comment)+
        //SHall this be '*'? Ambiguity?
    END
    )
;

fragment ObjectiveFragment returns tdl::Behaviour:
    'Objective:' testObjective+=[tdl::TestObjective|Identifier] ( "," testObjective+=[tdl::TestObjective|Identifier])*
fragment WithNameFragment returns tdl::Element:
    'With:'
    BEGIN
        //At least one element shall be provided? Ambiguity?
        NameFragment?
        (comment+=Comment)*
    END
;

fragment WithBehaviourFragment returns tdl::Behaviour:
    'With:'
    BEGIN
        //At least one element shall be provided? Ambiguity?
        NameFragment?
        ObjectiveFragment?
        (comment+=Comment)*
    END
;

fragment WithTDFragment returns tdl::TestDescription:
    'With:'
    BEGIN
        //At least one element shall be provided? Ambiguity?
        TDObjectiveFragment?
        (comment+=Comment)*
    END
;

fragment WithAtomicFragment returns tdl::AtomicBehaviour:
    'With:'
    BEGIN
        //At least one element shall be provided? Ambiguity?
        NameFragment?
        ObjectiveFragment?
        TimeLabelFragment?
        TimeConstraintFragment?
        (comment+=Comment)+
    END
;

fragment WithCombinedFragment returns tdl::CombinedBehaviour:
    'With:'
    BEGIN
        //At least one element shall be provided? Ambiguity?
        NameFragment?
        ObjectiveFragment?
        (comment+=Comment)*
        //TODO: periodic / exceptional as separate fragment(s) for combined behaviour
        (periodic+=PeriodicBehaviour)*
        (exceptional+=ExceptionalBehaviour)*
    END
;

fragment TDObjectiveFragment returns tdl::TestDescription:
    'Objective:' testObjective+=[tdl::TestObjective|Identifier] ( "," testObjective+=[tdl::TestObjective|Identifier])*
;

fragment ObjectiveFragment returns tdl::Behaviour:
    'Objective:' testObjective+=[tdl::TestObjective|Identifier] ( "," testObjective+=[tdl::TestObjective|Identifier])*
;


fragment NameFragment returns tdl::Element:
    'Name:' name=Identifier
;


fragment TimeLabelFragment returns tdl::AtomicBehaviour:
    'TimeLabel:' timeLabel=TimeLabel
;
@@ -638,6 +892,12 @@ EString returns ecore::EString:
    // | ID
;

LiteralValue returns ecore::EString:
    STRING
    | ('-'? INT ('.' INT)?)
;


Identifier returns ecore::EString:
    ID
;