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

+added textual syntax support for 1.4.1



Change-Id: I54cb468a04398ba9a99f1d5ee45fe1c4fb18db43
Signed-off-by: default avatarmakedonski <makedonski@informatik.uni-goettingen.de>
parent a4f5b6e9
Loading
Loading
Loading
Loading
+187 −10
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@
grammar org.etsi.mts.tdl.TDLan2 with org.eclipse.xtext.common.Terminals

import "http://www.eclipse.org/emf/2002/Ecore" as ecore
import "http://www.etsi.org/spec/TDL/1.4.0" as tdl 
import "http://www.etsi.org/spec/TDL/1.4.1" as tdl 

Package returns tdl::Package:
	{tdl::Package}
@@ -27,7 +27,7 @@ Action returns tdl::Action:
ActionReference returns tdl::ActionReference:
	'perform' 'action'
	action=[tdl::Action|Identifier]
	('(' actualParameter+=DataUse ( "," actualParameter+=DataUse)* ')' )?
	('(' actualParameter+=ParameterBinding ( "," actualParameter+=ParameterBinding)* ')' )?
	('on' componentInstance=[tdl::ComponentInstance|Identifier])?
	(
	'with'
@@ -139,6 +139,7 @@ Assertion returns tdl::Assertion:
	{tdl::Assertion}
	'assert'
	condition=DataUse
    ('on' componentInstance=[tdl::ComponentInstance|Identifier])?
	('otherwise' 'set' 'verdict' 'to' otherwise=DataUse)?
	('with'
	'{'
@@ -319,6 +320,10 @@ ComponentInstanceBinding returns tdl::ComponentInstanceBinding:
enum ComponentInstanceRole returns tdl::ComponentInstanceRole:
	SUT = 'SUT' | Tester = 'Tester';

enum GateTypeKind returns tdl::GateTypeKind:
    Message = 'Message' | Procedure = 'Procedure';


ComponentType returns tdl::ComponentType:
	{tdl::ComponentType}
	'Component' 'Type'
@@ -469,10 +474,73 @@ DataResourceMapping returns tdl::DataResourceMapping:
	';';

DataType returns tdl::DataType:
	SimpleDataType_Impl | StructuredDataType | Time;
	SimpleDataType_Impl | StructuredDataType | Time | ProcedureSignature | CollectionDataType;


ProcedureSignature returns tdl::ProcedureSignature:
    {tdl::ProcedureSignature}
    //'Structured' 'Data' 'Type'
    'Signature'
    name=Identifier
    ('(' parameter+=ProcedureParameter ( "," parameter+=ProcedureParameter)* ')')?
    (
    'with'
    '{'
        (comment+=Comment (comment+=Comment)*)?
        (annotation+=Annotation (annotation+=Annotation)*)?
    '}')?
    ';';

ProcedureParameter returns tdl::ProcedureParameter:
    kind=ParameterKind
    name=Identifier
    'of' 'type'
    dataType=[tdl::DataType|Identifier]
    (
    'with'
    '{'
        (comment+=Comment (comment+=Comment)*)?
        (annotation+=Annotation (annotation+=Annotation)*)?
    '}')?;

enum ParameterKind returns tdl::ParameterKind:
    In = 'In' | Out = 'Out' | Exception = 'Exception';


CollectionDataType returns tdl::CollectionDataType:
    {tdl::CollectionDataType}
    //'Structured' 'Data' 'Type'
    'Collection'
    name=Identifier
    'of' 'type'
    itemType=[tdl::DataType|Identifier]
    (
    'with'
    '{'
        (comment+=Comment (comment+=Comment)*)?
        (annotation+=Annotation (annotation+=Annotation)*)?
    '}')?;

CollectionDataInstance returns tdl::CollectionDataInstance:
    {tdl::CollectionDataInstance}

    dataType=[tdl::DataType|Identifier]
    name=Identifier
    'containing' '{' 
        (item+=StaticDataUse ("," item+=StaticDataUse)*)?
     
    '}'
    ('with'
    '{'
        (comment+=Comment (comment+=Comment)*)?
        (annotation+=Annotation (annotation+=Annotation)*)?
    '}')?
    ';'
    ;


DataUse returns tdl::DataUse:
	DataInstanceUse | FunctionCall | FormalParameterUse | TimeLabelUse | VariableUse | AnyValue | AnyValueOrOmit | OmitValue;
	DataInstanceUse | FunctionCall | PredefinedFunctionCall | FormalParameterUse | TimeLabelUse | VariableUse | AnyValue | AnyValueOrOmit | OmitValue;

DefaultBehaviour returns tdl::DefaultBehaviour:
	'default'
@@ -491,6 +559,21 @@ Identifier returns ecore::EString:
	ID
;

PredefinedIdentifierBinary returns ecore::EString:
    '+' | '-' | '*' | '/' | 'mod' 
  | '>' | '<' | '>=' | '<=' | '>='
  | '==' | '!=' | 'and' | 'or' | 'xor'
;

PredefinedIdentifierNot returns ecore::EString:
    'not'
;

PredefinedIdentifierSize returns ecore::EString:
    'size'
;


IdentifierDot returns ecore::EString:
	ID '.' ID
;
@@ -546,6 +629,34 @@ FunctionCall returns tdl::FunctionCall:
	'}')?
	;

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
    ')'
    ;



GateInstance returns tdl::GateInstance:
	{tdl::GateInstance}
@@ -573,6 +684,7 @@ GateReference returns tdl::GateReference:


GateType returns tdl::GateType:
    (kind=GateTypeKind)?
	'Gate' 'Type'
	name=Identifier
	'accepts'
@@ -600,7 +712,7 @@ InlineAction returns tdl::InlineAction:
	';';

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

Message returns tdl::Message:
@@ -608,7 +720,28 @@ Message returns tdl::Message:
	('sends' | (isTrigger?='triggers')) 
	argument=DataUse
	'to' 
	target+=Target ( "," target+=Target)* 
	target+=TargetMessage ( "," target+=TargetMessage)* 
	(
	'with'
	'{'
		(comment+=Comment (comment+=Comment)*)?
		(annotation+=Annotation (annotation+=Annotation)*)?
		('test' 'objectives' ':' testObjective+=[tdl::TestObjective|Identifier] ( "," testObjective+=[tdl::TestObjective|Identifier])* ';')?
		('name' name=Identifier)? //USE FOR STEPS?
		('time' 'label' timeLabel=TimeLabel)?
		('time' 'constraints' ':' timeConstraint+=TimeConstraint ( "," timeConstraint+=TimeConstraint)* ';' )?
	'}')?
	';'
	;

ProcedureCall returns tdl::ProcedureCall:
    sourceGate=[tdl::GateReference|IdentifierDot]
    'calls' 
    signature=[tdl::ProcedureSignature|Identifier]
    '('argument+=ParameterBinding ("," argument+=ParameterBinding)*')'
    'on' 
    target+=TargetProcedure
    //TODO: add support for responses
    (
    'with'
    '{'
@@ -717,7 +850,7 @@ OmitValue returns tdl::OmitValue:

PackageableElement returns tdl::PackageableElement:
//	AnnotationType | TestObjective | DataResourceMapping | DataElementMapping | SimpleDataType_Impl | SimpleDataInstance_Impl | StructuredDataType | StructuredDataInstance | Action_Impl | Function | Verdict | ComponentType | GateType | Time | TimeLabel | TestConfiguration | TestDescription;
	AnnotationType | TestObjective | DataResourceMapping | DataElementMapping | SimpleDataType_Impl | SimpleDataInstance_Impl | StructuredDataType | StructuredDataInstance | Action_Impl | Function | ComponentType | GateType | Time | TestConfiguration | TestDescription;
	AnnotationType | TestObjective | DataResourceMapping | DataElementMapping | SimpleDataType_Impl | SimpleDataInstance_Impl | StructuredDataType | StructuredDataInstance | Action_Impl | Function | ComponentType | GateType | Time | TestConfiguration | TestDescription | CollectionDataType | CollectionDataInstance | ProcedureSignature;

ParallelBehaviour returns tdl::ParallelBehaviour:
	'run' block+=Block ('in' 'parallel' 'to' block+=Block)* 
@@ -750,6 +883,7 @@ FormalParameter returns tdl::FormalParameter:

TimeLabelUse returns tdl::TimeLabelUse:
	'time' 'label' timeLabel=[tdl::TimeLabel|Identifier]
	('.' kind=TimeLabelUseKind)?
	//('(' argument+=ParameterBinding ( "," argument+=ParameterBinding)* ')' )?
	//( "." reduction+=[tdl::Member|Identifier])*
    (
@@ -762,6 +896,10 @@ TimeLabelUse returns tdl::TimeLabelUse:
    '}')?;


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


FormalParameterUse returns tdl::FormalParameterUse:
	'parameter'
	parameter=[tdl::FormalParameter|Identifier]
@@ -892,10 +1030,49 @@ StructuredDataType returns tdl::StructuredDataType:
    '}')?
    ';';

Target returns tdl::Target:
TargetMessage returns tdl::Target:
	targetGate=[tdl::GateReference|IdentifierDot]
	//TODO: check what the correct syntax shall be
	('where' 'it' 'is' 'assigned' 'to' variable=[tdl::Variable|Identifier])?
	(valueAssignment+=ValueAssignmentMessage)?
   	(
    'with'
    '{'
        (comment+=Comment (comment+=Comment)*)?
        (annotation+=Annotation (annotation+=Annotation)*)?
		('name' name=Identifier)?
    '}')?
    ;

TargetProcedure returns tdl::Target:
    targetGate=[tdl::GateReference|IdentifierDot]
    //TODO: check what the correct syntax shall be
    (valueAssignment+=ValueAssignmentProcedure ("," valueAssignment+=ValueAssignmentProcedure)*)?
    (
    'with'
    '{'
        (comment+=Comment (comment+=Comment)*)?
        (annotation+=Annotation (annotation+=Annotation)*)?
        ('name' name=Identifier)?
    '}')?
    ;


ValueAssignmentMessage returns tdl::ValueAssignment:
    //TODO: check what the correct syntax shall be
    'where' 'it' 'is' 'assigned' 'to' variable=[tdl::Variable|Identifier]
    (
    'with'
    '{'
        (comment+=Comment (comment+=Comment)*)?
        (annotation+=Annotation (annotation+=Annotation)*)?
        ('name' name=Identifier)?
    '}')?
    ;

ValueAssignmentProcedure returns tdl::ValueAssignment:
    //TODO: check what the correct syntax shall be
    'where' parameter=[tdl::Parameter|Identifier] 'is' 'assigned' 'to' variable=[tdl::Variable|Identifier]
    
    (
    'with'
    '{'
@@ -939,7 +1116,7 @@ TestDescription returns tdl::TestDescription:
TestDescriptionReference returns tdl::TestDescriptionReference:
	'execute'
	testDescription=[tdl::TestDescription|Identifier]
	('(' actualParameter+=DataUse ( "," actualParameter+=DataUse)* ')' )?
	('(' actualParameter+=ParameterBinding ( "," actualParameter+=ParameterBinding)* ')' )?
	('with'
	  '{'
		('bindings' '{' componentInstanceBinding+=ComponentInstanceBinding ( "," componentInstanceBinding+=ComponentInstanceBinding)* '}' )?
+10 −3
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import org.etsi.mts.tdl.PackageableElement;
import org.etsi.mts.tdl.Parameter;
import org.etsi.mts.tdl.ParameterBinding;
import org.etsi.mts.tdl.ParameterMapping;
import org.etsi.mts.tdl.ProcedureCall;
import org.etsi.mts.tdl.StructuredDataInstance;
import org.etsi.mts.tdl.StructuredDataType;
import org.etsi.mts.tdl.Target;
@@ -42,6 +43,7 @@ import org.etsi.mts.tdl.TestDescription;
import org.etsi.mts.tdl.TestDescriptionReference;
import org.etsi.mts.tdl.Timer;
import org.etsi.mts.tdl.TimerOperation;
import org.etsi.mts.tdl.ValueAssignment;
import org.etsi.mts.tdl.Variable;
import org.etsi.mts.tdl.VariableUse;
import org.etsi.mts.tdl.tdlPackage;
@@ -164,6 +166,11 @@ public class TDLan2ScopeProvider extends AbstractDeclarativeScopeProvider {
				} else if (context.eContainer() instanceof VariableUse) {
					IScope scope = Scopes.scopeFor(((StructuredDataType)((VariableUse)context.eContainer()).getVariable().getDataType()).getMember());
					return scope;
				} else if (context.eContainer() instanceof ProcedureCall) {
//					if (((FunctionCall)context.eContainer()).getFunction().get instanceof StructuredDataInstance) {
						IScope scope = Scopes.scopeFor(((ProcedureCall)context.eContainer()).getSignature().getParameter());
						return scope;
//					}
				}
			} else if (context instanceof MemberReference) {
				if (((DataUse)context.eContainer()).getReduction().indexOf(context)>0) {
@@ -211,9 +218,9 @@ public class TDLan2ScopeProvider extends AbstractDeclarativeScopeProvider {
					return scope;
				}
			}
			else if (context instanceof Target) {
				if (((Target)context).getTargetGate().getComponent()!=null) {
					IScope scope = Scopes.scopeFor(((Target)context).getTargetGate().getComponent().getType().getVariable());
			else if (context instanceof ValueAssignment) {
				if (((Target)context.eContainer()).getTargetGate().getComponent()!=null) {
					IScope scope = Scopes.scopeFor(((Target)context.eContainer()).getTargetGate().getComponent().getType().getVariable());
					return scope;
				}
			}