Search code examples
eclipsedslxtextxbasexcore

Xtext , Defining a Structure for a plot


i have to make a type curve that is a curve plot , the data is given by a CSV file (The interpreter is who read the data file). i have two type of values , x-axis, time (i think INT:INT) minutes:seconds format ; and y-axis voltage ( double ) . My grammar datatypes are the following :

Model:
elements+=Element*;

Element:
     DataType /* | Operation | Control*/ ;

DataType : 
     Text | Real 
;
Text: 
    ("String" | "Text") name=ID (value=STRING)?
;
Double returns ecore::EDouble:
     INT ('.' INT)?
;
Real: 
     ("Double" | "Real") name=ID (value=Double)?
;

I was traying to make a map in my grammar with this format : Curve(Double voltage,time INT:INT) but i dont know why it doesnt work . what do you think guys ? should i define a new type for the type time ? or how make the map properly? Thanks for your time

   CurveCollection : 
        'Curve['keys+=[Real]*','values+=Time*']'
;
 Time: 
     INT':'INT
 ;

I tried to define the structure , but i dont know if is going to work like to arrays of (keys , values ) like a Map in java


Solution

  • you can enable a default unique name validation by uncommenting in and rerunning the language workflow

    validator = {
        composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
    }
    

    alternatively you can implement a own unique name validation in <YourDsl>Validator