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

+ added rules for DataElementUse and other refinements

-> need to be tested further (potential ambiguities), ultimately using the rules from TX may be the better way forward to avoid maintaining another grammar, or at least perhaps reusing that by importing and refining
parent 5dbc15bd
Loading
Loading
Loading
Loading
+89 −11
Original line number Diff line number Diff line
@@ -8,7 +8,8 @@ import "http://www.eclipse.org/emf/2002/Ecore" as ecore

//#####################################################################################
DataUse returns DataUse:
	DynamicDataUse | StaticDataUse;
    //TODO: make sure that DataElementUse works -> may be clashing with others (requires deeper alignment and cleanup)
	DynamicDataUse | StaticDataUse | DataElementUse;

StaticDataUse returns StaticDataUse:
	SpecialValueUse | DataInstanceUse | LiteralValueUse;
@@ -16,17 +17,68 @@ StaticDataUse returns StaticDataUse:
DynamicDataUse returns DynamicDataUse:
	VariableUse | FunctionCall | PredefinedFunctionCall | FormalParameterUse | TimeLabelUse;

//Copied and adjusted from TDLtx 
DataElementUse returns DataElementUse:
	// XXX dataelementuse
	'TODO'
    //'unified' //this gets embedded in the first alternative somehow!? -> shouldn't be needed anyway
    //express also through table
    //              -   (binding) [index] [items]
    //anonymous            x                 x
    //type                 x                 x
    //instance      x      x         x        

    (   
//        //anonymous - split in case of problems
////        (ParameterBindingFragment | CollectionItemFragment)
////    ) | (
        //instance
        dataElement=[NamedElement|Identifier]
        UnassignedFragmentNamedElement?
        ParameterBindingFragment?
        ReductionFragment
    ) | (
        //type / anonymous (simplified, avoid duplication, otherwise remove "?")
        //DONE: empty parameters / collections? -> added
        //DONE: support simple data types as well? -> use any value instead
        //DONE: decide on prefix -> extract to comment? -> capture as name
        //(('new' | 'a') dataElement=[tdl::DataType|Identifier])?
        (
            //DONE: do we really need different ways? -> not for now!
            //name=('new' | 'a' | 'an' | 'the')
            'new' dataElement=[DataType|Identifier]
        )?
        UnassignedFragmentNamedElement?
        (ParameterBindingFragment | CollectionItemFragment)
    )
;

fragment UnassignedFragmentNamedElement returns DataElementUse:
    '<' unassignedMember=UnassignedMemberTreatment '>'
;

fragment CollectionItemFragment returns DataElementUse:
    '[' (item+=DataUse (',' item+=DataUse)*)? ']'
;

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

CollectionReference returns MemberReference:
    '[' collectionIndex=DataUse ']'
;


SpecialValueUse returns StaticDataUse:
	NoneValue | AnyValue | AnyNoneValue;

EString returns ecore::EString:
	ID;

Identifier:
    ID
;

DataInstanceUse returns DataInstanceUse:
	{DataInstanceUse}
	((dataInstance=[DataInstance|NumberAsIdentifier] |
@@ -62,8 +114,9 @@ enum UnassignedMemberTreatment returns UnassignedMemberTreatment:
LiteralValueUse returns LiteralValueUse:
	{LiteralValueUse}
	(value=String0 | intValue=BigInt | boolValue=Boolean)
	(':' dataType=[DataType|EString])?
	// XXX check arugment and reduction
	(':' dataType=[DataType|EString]
       (ParameterBindingFragment | ReductionFragment)
	)?
;

BigInt returns ecore::EBigInteger:
@@ -95,9 +148,19 @@ VariableUse returns VariableUse:
	("." reduction+=MemberReference)*;

TimeLabelUse returns TimeLabelUse:
	// XXX need to add kind
	// XXX need to add predefined function
	timeLabel=[TimeLabel|EString];
	// XXX need to add predefined function -> for what
	timeLabel=[TimeLabel|EString]
    ('.' kind=TimeLabelUseKind)?
;	

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


fragment ParameterBindingFragment returns DataUse:
    LParen (argument+=ParameterBinding ( ',' argument+=ParameterBinding)*)? RParen
;

ParameterBinding returns ParameterBinding:
	parameter=[Parameter|EString]
@@ -119,8 +182,14 @@ AnyNoneValue returns AnyValueOrOmit:
String0 returns ecore::EString:
	STRING;

ComponentInstanceBinding returns ComponentInstanceBinding:
    formalComponent=[ComponentInstance|Identifier]
    '->' actualComponent=[ComponentInstance|Identifier]
;


PredefinedFunctionCall returns PredefinedFunctionCall:
	// XXX add all predefined functions
	// XXX add all predefined functions -> done?
	PredefinedFunctionCallSize | PredefinedFunctionCallNot | PredefinedFunctionCallBinary;

PredefinedFunctionCallSize returns PredefinedFunctionCall:
@@ -128,7 +197,7 @@ PredefinedFunctionCallSize returns PredefinedFunctionCall:
	'('
	actualParameters+=DataUse
	')'
	// XXX check reduction
	// XXX check reduction -> no reduction?
;

PredefinedFunctionCallNot returns PredefinedFunctionCall:
@@ -154,3 +223,12 @@ PredefinedIdentifierNot returns ecore::EString:

PredefinedIdentifierSize returns ecore::EString:
	'size';
	
LParen:
    '('
;

RParen:
    ')'
;
	
 No newline at end of file