Skip to content

Instantly share code, notes, and snippets.

@vorachet
Created June 10, 2022 09:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vorachet/ac51bfb3a51a4040022733bcc81d0f3b to your computer and use it in GitHub Desktop.
Save vorachet/ac51bfb3a51a4040022733bcc81d0f3b to your computer and use it in GitHub Desktop.
Grammar design for ConOpsDsl
/*****************************************************************************
* ConOpsDsL Implementation
* Copyright (c) 2022 Script Conductive Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* @license LGPL-3.0-or-later <http://spdx.org/licenses/LGPL-3.0-or-later>
*
* Contributor:
* Vorachet Jaroensawas, SC
*
*****************************************************************************/
grammar org.awesomedsls.conopsdsl.ConOpsDsl with org.eclipse.xtext.common.Terminals
generate conOpsDsl "http://www.awesomedsls.org/conopsdsl/ConOpsDsl"
Model:
includes+=Include*
images+=Image*
annotations+=Annotation*
stakeholders+=Stakeholder*
functions+=Function*
operations+=Operation*
stages+=Stage*
matrixViewConifgurations+=MatrixViewConifguration*
compositionViewConifgurations+=CompositionViewConifguration*
projects+=Project*;
Include:
ImportDefKeyword importURI=STRING;
Image:
SimpleImage | ImageWithLabels;
SimpleImage: SimpleImageDefKeyword name=Name
Path SizeSetting BackgroundColor
;
Label:
LabelDefKeyword SetTextKeyword text=STRING ColorSetting?;
ImageWithLabels: ImageWithLabelsDefKeyword name=Name
Path SizeSetting BackgroundColor
(SetTopLeftKeyword '('
topLeftLabels+=Label*
(SetFunctionsKeyword topLeftFunctions+=[Function]*)?
(SetOperationsKeyword topLeftOperations+=[Operation]*)?
(SetStagesKeyword topLeftStages+=[Stage]*)?
')')?
(SetBottomLeftKeyword '('
bottomLeftLabels+=Label*
(SetFunctionsKeyword bottomLeftFunctions+=[Function]*)?
(SetOperationsKeyword bottomLeftOperations+=[Operation]*)?
(SetStagesKeyword bottomLeftStages+=[Stage]*)?
')')?
(SetBottomRightKeyword '('
bottomRightLabels+=Label*
(SetFunctionsKeyword bottomRightFunctions+=[Function]*)?
(SetOperationsKeyword bottomRightOperations+=[Operation]*)?
(SetStagesKeyword bottomRightStages+=[Stage]*)?
')')?
(SetTopRightKeyword '('
topRightLabels+=Label*
(SetFunctionsKeyword topRightFunctions+=[Function]*)?
(SetOperationsKeyword topRightOperations+=[Operation]*)?
(SetStagesKeyword topRightStages+=[Stage]*)?
')')?
;
Project:
ProjectDefKeyword
name=STRING
Description?
(SetImagesKeyword images+=[Image]*)?
(SetWebContentSettingKeyword webContentSetting=WebContentSetting)?
Views
;
MatrixViewConifguration:
MatrixViewConifgurationDefKeyword name=Name '('
ConfColumnNames
')';
MatrixView:
{MatrixView} MatrixViewDefKeyword ObjectID?
DisplayName?
(SetImagesKeyword images+=[Image]*)?
Stages?
(SetConfigurationKeyword configuration=[MatrixViewConifguration])?;
CompositionViewConifguration:
CompositionViewConifgurationDefKeyword name=Name;
CompositionView:
CompositionViewDefKeyword ObjectID?
DisplayName?
(SetImagesKeyword images+=[Image]*)?
SetStageKeyword stage=[Stage]
(SetConfigurationKeyword configuration=[CompositionViewConifguration])?;
Annotation:
AnnotationDefKeyword name=Name
Description?
SetSymbolKeyword symbol=OID
SetThemeKeyword
SetHighKeyword highThemeColor=Color
SetMediumKeyword mediumThemeColor=Color
SetLowKeyword lowThemeColor=Color
SetTextKeyword
SetHighKeyword highValueText=OID
SetMediumKeyword mediumValueText=OID
SetLowKeyword lowValueText=OID;
AnnotationAttachment:
'<' weight=Weight annotation=[Annotation] (SetTextKeyword text=STRING)? '>';
Stakeholder: StakeholderDefKeyword ObjectID? name=Name
Description? DisplayName? Parent? Parents?
AnnotationAttachments;
Function: FunctionDefKeyword ObjectID? name=Name
Description? DisplayName? Parent? Parents?
Stakeholders?
AnnotationAttachments;
Operation: OperationDefKeyword ObjectID? name=Name
Description? DisplayName? Parent? Parents?
Functions?
Stakeholders?
AnnotationAttachments;
Stage: StageDefKeyword ObjectID? name=Name
Description? DisplayName? Parent? Parents?
Operations?
AnnotationAttachments;
ImportDefKeyword: 'import';
SimpleImageDefKeyword: 'image';
LabelDefKeyword: 'label';
ImageWithLabelsDefKeyword: 'imageWithLabels';
ProjectDefKeyword: 'project';
AnnotationDefKeyword: 'annotation';
MatrixViewConifgurationDefKeyword: 'matrixViewConfiguration';
MatrixViewDefKeyword: 'matrixView';
CompositionViewConifgurationDefKeyword: 'compositionViewConfiguration';
CompositionViewDefKeyword: 'compositionView';
StakeholderDefKeyword: 'stakeholder';
FunctionDefKeyword: 'function';
OperationDefKeyword: 'operation';
StageDefKeyword: 'stage';
SetDescriptionKeyword: 'description:';
SetDisplayNameKeyword: 'displayName:';
SetParentKeyword: 'parent:';
SetParentsKeyword: 'parents:';
SetObejctIdKeyword: '@';
SetStakeholdersKeyword: 'stakeholders:';
SetTopLeftKeyword: 'topLeft:';
SetBottomLeftKeyword: 'bottomLeft:';
SetBottomRightKeyword: 'bottomRight:';
SetTopRightKeyword: 'topRight:';
SetFunctionsKeyword: 'functions:';
SetOperationsKeyword: 'operations:';
SetStagesKeyword: 'stages:';
SetColorKeyword: 'color:';
SetTextKeyword: 'text:';
SetImagesKeyword: 'images:';
SetWebContentSettingKeyword: 'webContentSetting:';
SetStageKeyword: 'stage:';
SetConfigurationKeyword: 'configuration:';
SetViewsKeyword: 'views:';
SetPathKeyword: 'path:';
SetSizeKeyword: 'size:';
SetBackgroundColorKeyword: 'backgroundColor:';
SetCustomStageColNameKeyword: 'customStageColumnName:';
SetCustomOperationColNameKeyword: 'customOperationColumnName:';
SetCustomFunctionColNameKeyword: 'customFunctionColumnName:';
SetCustomStkaeholderColNameKeyword: 'customStakeholderColumnName:';
SetSymbolKeyword: 'symbol:';
SetThemeKeyword: 'theme:';
SetHighKeyword: 'high:';
SetMediumKeyword: 'medium:';
SetLowKeyword: 'low:';
fragment ColorSetting *: SetColorKeyword color=Color;
fragment Path *: SetPathKeyword path=STRING;
fragment SizeSetting *: SetSizeKeyword size=Size;
fragment BackgroundColor *: (SetBackgroundColorKeyword backgroundColor=Color)?;
fragment Views *:
(SetViewsKeyword '('
matrixViews+=MatrixView*
compositionViews+=CompositionView*
')')?
;
fragment Description *: SetDescriptionKeyword description=STRING;
fragment DisplayName *: SetDisplayNameKeyword displayName=STRING;
fragment Parent *: SetParentKeyword parent=[Function];
fragment Parents *: SetParentsKeyword parents+=[Function]*;
fragment ObjectID *: SetObejctIdKeyword oid=OID;
fragment Stakeholders *: SetStakeholdersKeyword stakeholders+=[Stakeholder]*;
fragment Functions *: SetFunctionsKeyword funcs+=[Function]*;
fragment Operations *: SetOperationsKeyword operations+=[Operation]*;
fragment Stages *: SetStagesKeyword stages+=[Stage]*;
fragment AnnotationAttachments *: annotationAttachments+=AnnotationAttachment*;
fragment ConfColumnNames *:
(SetCustomStageColNameKeyword stageColumnName=STRING)?
& (SetCustomOperationColNameKeyword operationColumnName=STRING)?
& (SetCustomFunctionColNameKeyword functionColumnName=STRING)?
& (SetCustomStkaeholderColNameKeyword stakeholderColumnName=STRING)?
;
enum Size: SMALL | MEDIUM | LARGE;
enum WebContentSetting:
USE_CSS_JS_FILES_FROM_INTERNET | USE_LOCAL_CSS_JS_FILES;
enum Weight:
HIGH | MEDIUM | LOW;
enum Color:
BLUE | GREY | GREEN | RED | ORANGE | LIGHTBLUE | BLACK | WHITE;
OID: Name | STRING;
Name: ID;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment