grammar org.xtext.example.mydsl.EinDsl with org.eclipse.xtext.common.Terminals

generate einDsl "http://www.xtext.org/example/mydsl/EinDsl"


Model:
	greetings=Query;

Query:
	(key=QTypekeyWord)? (aggregation=Aggregation)? (measure=MeasureList) ((groupBy+=Group)? &(condition=Condtition*)? &(range=Transition)?)(chartType=ChartType)? ;


	QTypekeyWord:
		qKeyword='plot'
	;

Aggregation:
	agg=('average'|'number of'|'total')
;

Condtition:
	con+='for' (dimValue=DimensionValue 'as' dimen=Dimension) |
	conTimeCurrent= 'for' thisTimeGroup=ThisTimeGroup |
	conlastTimePast  ='for' lastTimeGroup =LastTimeGroup |
	conlastNTimePast  ='for'lastNTimeGroup =LastNTimeGroup|
	conDayTimeGroup ='for' dayTimeGroup=DayTimeGroup
;

MeasureList : names+=Measure ("and" names+=Measure)*;


EinString:ID |SPECIAL;

SPECIAL:
	('/' | ';' | ',' | '!' | '§' | '%' | '&' | '(' | ')' | '?' | '*' | '+' | '.' | '-' | '|' | '[' | ']' | '#' | '@' |'{'|'}' |'$' |'^' |'~' |INT |':');

Measure:EinString+;


Dimension:EinString+;

DimensionValue:
	value=EinString+
;

GroupList:
 "by" (dimGroup=Dimension("by" timeGroup+=TimeGroup)? )|timeGroup+= TimeGroup
;

Group:

	"by" ((dimGroup=Dimension("by" timeGroup+=TimeGroup)? )|timeGroup+= TimeGroup)

;

Transition:

	'from' dateStart=Date 'to' dateEnd=Date
;

TimeGroup:
	timeGroup=('day'|'week'|'month'|'quarter'|'year')
;

ThisTimeGroup:
	thisTimeGroup='this'('year'|'month'|'week')|'ytd'|'mtd'
 ;

LastTimeGroup:
	lastTimeGroup= 'last'('year'|'quarter'|'month'|'week')
;

LastNTimeGroup:
	lastTimeGroup= 'last'INT('days'|'weeks'|'months')
;

DayTimeGroup:
	dayTimeGroup =('today'|'yesterday')
;

ChartType:
	chartType ='as'('pie'|'column'|'bar'|'line')'chart'
;



Date:
	d=Day m=Month y=Year ;


Day : ID ;
Month : ID ;
Year : INT ;
