Commit 4ae1c42d authored by Philip Makedonski's avatar Philip Makedonski
Browse files

+ completed grammar migration (refinements and new elements pending)

parent 859d437f
Loading
Loading
Loading
Loading
+412 −99
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ PackageableElement returns tdl::PackageableElement:
     | ProcedureSignature 
     | Action_Impl | Function 
     | PredefinedFunction 
//     | Time 
     | Time 
     | ComponentType | GateType 
     | TestConfiguration 
     | TestDescription 
@@ -206,7 +206,6 @@ MemberAssignment returns tdl::MemberAssignment:
    WithCommentFragment?
;

//TODO: test below
//TODO: stick with existing syntax and address urgent issues or
//      invent new parts? -> stick with existing and refine!!!! 
//      currently: a bit of reinvention
@@ -293,24 +292,36 @@ Function returns tdl::Function:
enum UnassignedMemberTreatment returns tdl::UnassignedMemberTreatment:
    AnyValue = '?' | AnyValueOrOmit = '*';

//TODO: check how this was handled before
//TODO: check all prefix fragments and whether there shall be 
//      with fragments as well for compatibility
PredefinedFunction returns tdl::PredefinedFunction:
    {tdl::PredefinedFunction}
    PrefixFragment?
    'Predefined'
    name=Identifier
    (name=PredefinedIdentifierBinary
        | name=PredefinedIdentifierNot
        | name=PredefinedIdentifierSize
    )
    ('returns' returnType=[tdl::DataType|Identifier])?
    WithCommentFragment?
;

//## Data Use
PredefinedIdentifierBinary returns ecore::EString:
    '+' | '-' | '*' | '/' | 'mod' 
  | '>' | '<' | '>=' | '<=' //TODO: fix extra '>=' also in TDLan2
  | '==' | '!=' | 'and' | 'or' | 'xor'
;

//TODO: continue with data use...
PredefinedIdentifierNot returns ecore::EString:
    'not'
;

PredefinedIdentifierSize returns ecore::EString:
    'size'
;

//## Data Use

DataUse returns tdl::DataUse:
    StaticDataUse | DynamicDataUse
    StaticDataUse | =>DynamicDataUse
;

ParameterBinding returns tdl::ParameterBinding:
@@ -325,12 +336,11 @@ MemberReference returns tdl::MemberReference:
    {tdl::MemberReference}
    //PrefixFragment?
    member=[tdl::Member|Identifier] 
    //('[' collectionIndex=DataUse ']')? 
    (->'[' collectionIndex=DataUse ']')? 
    //TODO: this is ambiguous    
    //WithNameFragment?
;

//TODO: Synthetic
CollectionReference returns tdl::MemberReference:
    //PrefixFragment?
    '[' collectionIndex=DataUse ']'
@@ -339,71 +349,108 @@ CollectionReference returns tdl::MemberReference:
;

StaticDataUse returns tdl::StaticDataUse:
    DataInstanceUse 
//    DataInstanceUse
    GenericDataInstanceUse
    | AnonymousDataInstanceUse 
    | SpecialValueUse
    | LiteralValueUse
;

DataInstanceUse returns tdl::DataInstanceUse:
GenericDataInstanceUse returns tdl::DataInstanceUse:
    {tdl::DataInstanceUse}
    (dataInstance=[tdl::DataInstance|Identifier]
    |
    ('a' dataType=[tdl::StructuredDataType|Identifier]))
    UnassignedFragment?
    ParameterBindingFragment?
    //TODO: what if PrefixFragment?
    ReductionFragment
;

GenericMemberReference returns tdl::MemberReference:
    {tdl::MemberReference}
    //PrefixFragment?
    (
        ReferencedDataInstance
//        | AnonymousDataInstanceWithType
           //TODO: some ambiguity with UnassignedMemberTreatment
//        | AnonymousDataInstanceWithoutType
//        | AnonymousCollection
    ) 
    member=[tdl::Member|Identifier] 
    (->'[' collectionIndex=DataUse ']')? 
    //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]
AnonymousDataInstanceUse returns tdl::DataInstanceUse:
    UnassignedFragment?
    (
    ParameterBindingFragment
        //TODO: reduction problematic
//        |
//        (   (reduction+=CollectionReference)?
//            ('.' reduction+=MemberReference)*
;

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

fragment ReductionFragment returns tdl::DataUse:
    (->reduction+=CollectionReference)?
    ('.' reduction+=GenericMemberReference)*
;

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

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 BareParameterBindingFragment returns tdl::DataUse:
    =>(argument+=ParameterBinding ( "," argument+=ParameterBinding)*)
;

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)*)? ']'

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 
@@ -435,39 +482,90 @@ OmitValue returns tdl::OmitValue:
    //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
    //TODO: add option to have the type after wards without any keyword e.g. 100 s?
//    (dataType=[tdl::DataType|Identifier])?
    ('of' 'type' dataType=[tdl::DataType|Identifier])?
    //TODO: ambiguity
    //WithNameFragment?
    //Reduction and argument are excluded
;

DynamicDataUse returns tdl::DynamicDataUse:
    FunctionCall 
    | FormalParameterUse
    | VariableUse 
    | PredefinedFunctionCall
    | TimeLabelUse 
;

FunctionCall returns tdl::FunctionCall:
//    PrefixFragment?
    //TODO: refine syntax
    'instance' 'returned' 'from'
    function=[tdl::Function|Identifier] 
    '(' BareParameterBindingFragment? ')'
    ReductionFragment
    //WithNameFragment?
;

FormalParameterUse returns tdl::FormalParameterUse:
//    PrefixFragment?
    'parameter'
    parameter=[tdl::FormalParameter|Identifier]
    ParameterBindingFragment?
    ReductionFragment
    //WithNameFragment?
;

VariableUse returns tdl::VariableUse:
    //TODO: try to adjust syntax so that -> is not necessary
//    PrefixFragment?
    componentInstance=[tdl::ComponentInstance|Identifier]
    '->' variable=[tdl::Variable|Identifier]
    ParameterBindingFragment?
    ReductionFragment
    //WithNameFragment?
;

PredefinedFunctionCall returns tdl::PredefinedFunctionCall:
    PredefinedFunctionCallSize
    | PredefinedFunctionCallNot 
    | PredefinedFunctionCallBinary
;

PredefinedFunctionCallSize returns tdl::PredefinedFunctionCall:
    function=[tdl::PredefinedFunction|PredefinedIdentifierSize] 
    '(' actualParameters+=DataUse ')'
;


PredefinedFunctionCallNot returns tdl::PredefinedFunctionCall:
    function=[tdl::PredefinedFunction|PredefinedIdentifierNot] 
    '(' actualParameters+=DataUse ')'
;

PredefinedFunctionCallBinary returns tdl::PredefinedFunctionCall:
    '('
    actualParameters+=DataUse 
    function=[tdl::PredefinedFunction|PredefinedIdentifierBinary] 
    actualParameters+=DataUse
    ')'
;

//# Time

Timer returns tdl::Timer:
    {tdl::Timer}
Time returns tdl::Time:
    {tdl::Time}
    PrefixFragment?
    'timer'
    'Time'
    name=Identifier
    WithCommentFragment?
;

TimeConstraint returns tdl::TimeConstraint:
    //TODO: this is ambiguous    
    //PrefixFragment?
    timeConstraintExpression=DataUse
    //WithCommentFragment?
;

TimeLabel returns tdl::TimeLabel:
    {tdl::TimeLabel}
    //TODO: this is ambiguous    
@@ -476,10 +574,96 @@ TimeLabel returns tdl::TimeLabel:
    //WithCommentFragment?
;

TimeLabelUse returns tdl::TimeLabelUse:
    //    PrefixFragment?
    //TODO: refine syntax
    'time' 'label' timeLabel=[tdl::TimeLabel|Identifier]
    ('.' kind=TimeLabelUseKind)?
    //TODO: Add parameters and reductions?
    //ParameterBindingFragment
    //ReductionFragment
    //WithNameFragment?
;


enum TimeLabelUseKind returns tdl::TimeLabelUseKind:
    Last = 'Last' | Previous = 'Previous' | First = 'First'
;

TimeConstraint returns tdl::TimeConstraint:
    //TODO: this is ambiguous    
    //PrefixFragment?
    timeConstraintExpression=DataUse
    //WithCommentFragment?
;

Timer returns tdl::Timer:
    {tdl::Timer}
    PrefixFragment?
    'timer'
    name=Identifier
    WithCommentFragment?
;

TimeOperation returns tdl::TimeOperation: 
    Wait | Quiescence
;

Wait returns tdl::Wait: 
    PrefixFragment?
    ( 'component' componentInstance=[tdl::ComponentInstance|Identifier])
    'waits' 'for'
    period=DataUse
    WithAtomicFragment?
;

Quiescence returns tdl::Quiescence: 
    PrefixFragment?
    //TODO: improve syntax
    (
        'component' componentInstance=[tdl::ComponentInstance|Identifier] 
        | 'gate' gateReference=[tdl::GateReference|IdentifierDot]
    )
    'is' 'quiet' 'for'
    period=DataUse 
    WithAtomicFragment?
;


TimerOperation returns tdl::TimerOperation: 
    TimerStart | TimerStop | TimeOut
;

TimerStart returns tdl::TimerStart:
    PrefixFragment?
    'start'
    componentInstance=[tdl::ComponentInstance|Identifier]
    '.'
    timer=[tdl::Timer|Identifier]
    'for' period=DataUse
    WithAtomicFragment?
;

TimerStop returns tdl::TimerStop:
    PrefixFragment?
    'stop'
    componentInstance=[tdl::ComponentInstance|Identifier]
    '.'
    timer=[tdl::Timer|Identifier]
    WithAtomicFragment?
;

TimeOut returns tdl::TimeOut:
    PrefixFragment?
    componentInstance=[tdl::ComponentInstance|Identifier]
    '.'
    timer=[tdl::Timer|Identifier]
    //TODO: refine syntax
    'times' 'out'
    WithAtomicFragment?
;


//# Test Configuration

GateType returns tdl::GateType:
@@ -489,7 +673,7 @@ GateType returns tdl::GateType:
    name=Identifier
    (extension=Extension)?
    //TODO: revert to 'accepts'
    'supports' dataType+=[tdl::DataType|Identifier] ( "," dataType+=[tdl::DataType|Identifier])*
    'accepts' dataType+=[tdl::DataType|Identifier] ( "," dataType+=[tdl::DataType|Identifier])*
    WithCommentFragment?  
;

@@ -565,6 +749,7 @@ TestConfiguration returns tdl::TestConfiguration:
TestDescription returns tdl::TestDescription:
    PrefixFragment?
    'TestDescription'
    //TODO: consider better way to specify / indicate local ordering 
    (isLocallyOrdered?='Implementation')?
    name=Identifier
    ('(' formalParameter+=FormalParameter ( "," formalParameter+=FormalParameter)* ')' )?
@@ -720,44 +905,175 @@ PeriodicBehaviour returns tdl::PeriodicBehaviour:
//## Atomic Behaviour

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

Break returns tdl::Break:
    {tdl::Break}
    PrefixFragment?
    'break'
    WithAtomicFragment?
;

TimerStart returns tdl::TimerStart:
Stop returns tdl::Stop:
    {tdl::Stop}
    PrefixFragment?
    'start'
    componentInstance=[tdl::ComponentInstance|Identifier]
    '.'
    timer=[tdl::Timer|Identifier]
    'for' period=DataUse
    'terminate'
    WithAtomicFragment?
;

TimerStop returns tdl::TimerStop:
VerdictAssignment returns tdl::VerdictAssignment:
    PrefixFragment?
    'stop'
    componentInstance=[tdl::ComponentInstance|Identifier]
    '.'
    timer=[tdl::Timer|Identifier]
    'set' 'verdict' 'to'
    verdict=DataUse
    WithAtomicFragment?
;

TimeOut returns tdl::TimeOut:
Assertion returns tdl::Assertion:
    {tdl::Assertion}
    PrefixFragment?
    componentInstance=[tdl::ComponentInstance|Identifier]
    '.'
    timer=[tdl::Timer|Identifier]
    'expired'
    'assert'
    condition=DataUse
    ('on' componentInstance=[tdl::ComponentInstance|Identifier])?
    //TODO: simplify syntax
    ('otherwise' 'set' 'verdict' 'to' otherwise=DataUse)?
    WithAtomicFragment?
;

Interaction returns tdl::Interaction: 
    Message | ProcedureCall | ProcedureCallResponse
;

Message returns tdl::Message:
    PrefixFragment?
    sourceGate=[tdl::GateReference|IdentifierDot]
    ('sends' | (isTrigger?='triggers')) 
    argument=DataUse
    'to' 
    target+=TargetMessage ( "," target+=TargetMessage)* 
    WithAtomicFragment?
;

TargetMessage returns tdl::Target:
    //TODO: ambiguity?
    //PrefixFragment?
    targetGate=[tdl::GateReference|IdentifierDot]
    //TODO: check what the correct syntax shall be
    (valueAssignment+=ValueAssignmentMessage)?
    //WithNameFragment?
;

ValueAssignmentMessage returns tdl::ValueAssignment:
    //TODO: ambiguity?
    //PrefixFragment?
    //TODO: check what the correct syntax shall be
    'where' 'it' 'is' 'assigned' 'to' variable=[tdl::Variable|Identifier]
    //WithNameFragment?
;

ProcedureCall returns tdl::ProcedureCall:
    //TODO: ambiguity?
    //PrefixFragment?
    //TODO: async await pattern? -> it is actually sync
    sourceGate=[tdl::GateReference|IdentifierDot]
    'calls' 
    signature=[tdl::ProcedureSignature|Identifier]
    '('argument+=ParameterBinding ("," argument+=ParameterBinding)*')'
    'on' 
    target+=TargetProcedure
    //TODO: pull out name?
    WithAtomicFragment?
;

ProcedureCallResponse returns tdl::ProcedureCall:
    sourceGate=[tdl::GateReference|IdentifierDot]
    'responds'
    'with' 
    signature=[tdl::ProcedureSignature|Identifier]
    '('argument+=ParameterBinding ("," argument+=ParameterBinding)*')'
    'to' 
    target+=TargetProcedure
    WithAtomicFragment?
;

TargetProcedure returns tdl::Target:
    //TODO: ambiguity?
    //PrefixFragment?
    targetGate=[tdl::GateReference|IdentifierDot]
    //TODO: check what the correct syntax shall be
    (valueAssignment+=ValueAssignmentProcedure ("," valueAssignment+=ValueAssignmentProcedure)*)?
    //WithNameFragment?
;

ValueAssignmentProcedure returns tdl::ValueAssignment:
    //TODO: ambiguity?
    //PrefixFragment?
    //TODO: check what the correct syntax shall be
    'where' parameter=[tdl::Parameter|Identifier] 'is' 'assigned' 'to' variable=[tdl::Variable|Identifier]
    //WithNameFragment?
;
    
TestDescriptionReference returns tdl::TestDescriptionReference:
    //TODO: ambiguity?
    //PrefixFragment?
    'execute'
    testDescription=[tdl::TestDescription|Identifier]
    //TODO: mandatory parentheses? 
    ('(' actualParameter+=ParameterBinding ( "," actualParameter+=ParameterBinding)* ')' )?
    (BEGIN
        //TODO: commas? 
        componentInstanceBinding+=ComponentInstanceBinding+
    END)?
    WithAtomicFragment?
;

ComponentInstanceBinding returns tdl::ComponentInstanceBinding:
    //TODO: ambiguity?
    //PrefixFragment?
    'bind' formalComponent=[tdl::ComponentInstance|Identifier]
    'to' actualComponent=[tdl::ComponentInstance|Identifier]
    WithNameFragment?
;

ActionBehaviour returns tdl::ActionBehaviour: 
    ActionReference | InlineAction
;

ActionReference returns tdl::ActionReference:
    PrefixFragment?
    //TODO: simplify syntax further
    'perform' //'action'
    action=[tdl::Action|Identifier]
    ('(' actualParameter+=ParameterBinding ( "," actualParameter+=ParameterBinding)* ')' )?
    ('on' componentInstance=[tdl::ComponentInstance|Identifier])?
    WithAtomicFragment?
;

InlineAction returns tdl::InlineAction:
    PrefixFragment?
    //TODO: simplify syntax further
    'perform' 'action' ':'
    body=EString
    ('on' componentInstance=[tdl::ComponentInstance|Identifier])?
    WithAtomicFragment?
;

Assignment returns tdl::Assignment:
    PrefixFragment?
    //TODO: shall be mandatory?
    (componentInstance=[tdl::ComponentInstance|Identifier] '->')?
    variable=VariableUse
    '=' 
    expression=DataUse
    WithAtomicFragment?
;


//# Auxiliary
@@ -911,9 +1227,6 @@ QIdentifier returns ecore::EString:
;





//## Terminals
    
// The following synthetic tokens are used for the indentation-aware blocks -> moved to extended grammar