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

* refined collection index, cast data use, and anonymous data element use, #153, #155

-> use .get[i] for collection index, use (...) / [...] or new (...) / [...] or new Type (...) / [...] for anonymous data uses
parent 105fe261
Loading
Loading
Loading
Loading
Loading
+23 −17
Original line number Diff line number Diff line
@@ -367,7 +367,7 @@ DataUseWrapped returns tdl::DataUse:
;

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

@@ -383,22 +383,30 @@ fragment CheckFragment returns tdl::DataUse:
ParameterBinding returns tdl::ParameterBinding:
    parameter=[tdl::Parameter|Identifier]
//    ('.' parameter+=[tdl::Parameter|Identifier])*
    ('|' ParameterReductionFragment)?
    (
    '|' //TODO: is there a better way?
    ParameterReductionFragment
    )?
    '=' dataUse=DataUse
;

fragment ParameterReductionFragment returns tdl::ParameterBinding:
    (->reduction+=CollectionReference)?
    (reduction+=CollectionReference)?
    ('.' reduction+=MemberReference)*
;


MemberReference returns tdl::MemberReference:
    member=[tdl::Member|Identifier] 
    (->'[' collectionIndex=DataUse ']')? 
    (
    '.' 'get' //TODO: other keyword?
    '[' collectionIndex=DataUse ']'
    )? 
;
;

CollectionReference returns tdl::MemberReference:
    '.' 'get' //TODO: other keyword?
    '[' collectionIndex=DataUse ']'
;

@@ -468,8 +476,12 @@ LiteralValueUse returns tdl::LiteralValueUse:

CastDataUse returns tdl::CastDataUse:
	LParen
	//TODO: switch to 'from' keword?
    '<' dataType=[tdl::DataType|Identifier] '>'
    //dataType=[tdl::DataType|Identifier] 'from' 
	dataUse=DataUse
	//TODO: causes ambiguity
//	'as' dataType=[tdl::DataType|Identifier]
    RParen
	(ParameterBindingFragment | ReductionFragment)
;
@@ -562,9 +574,11 @@ DataElementUse returns tdl::DataElementUse:
        	//name=('new' | 'a' | 'an' | 'the')
        	//TODO: is this still used?
        	//TODO: this is clashing with the above during serialisation
//        	NewElementFragment -> needed for serialisation
//        	'<' dataElement=[tdl::DataType|Identifier] '>'
        	'new' dataElement=[tdl::DataType|Identifier]? //TODO: keep optional? -> too confusing?
			//TODO: this is still needed and breaks translation / serialisation 
			//		-> capture as name for now
        	name='new' 
        	dataElement=[tdl::DataType|Identifier]? //TODO: keep optional? -> too confusing?
        )?
        UnassignedFragmentNamedElement?
        //ParameterBinding is clashing with predefined function binary
@@ -582,14 +596,6 @@ fragment CollectionItemFragment returns tdl::DataElementUse:
    '[' (item+=DataUse (',' item+=DataUse)*)? ']'
;

fragment NewElementFragment returns tdl::DataElementUse:
    comment+=NewElementComment
;

NewElementComment returns tdl::Comment:
	body='new'
;



//# Time
@@ -1703,7 +1709,7 @@ DataReferenceAsArgument returns to::DataReference:
;

BindingDataReference returns to::DataReference:
    //TODO: review
    //TODO: review -> needs urgent revision! any data use? or remove altogether?
    content=StaticDataUse
;