|
|
Re: Multiple Entities within an Entity [message #1806395 is a reply to message #1806351] |
Wed, 08 May 2019 12:23 |
J Bouwhuis Messages: 17 Registered: April 2019 |
Junior Member |
|
|
@Christian thanks a lot for your answer. I already figured it out myself by now, but I still much appreciate your answer. You are right indeed (the 'if' keyword was set to be only specified once). I rewrote the DSL and added comments to it (see below). It now works as it should. Thanks!
grammar org.xtext.example.mydsl.FinalDsl with org.eclipse.xtext.common.Terminals
generate finalDsl "http://www.xtext.org/example/mydsl/FinalDsl"
Model:
'functionName' name = STRING
functions += FunctionElements*
;
// Function elements of which the model exists. The model can contain
// library functions, for loops, and if/else statements.
FunctionElements:
(
functions += libraryFunctionsEnum |
forLoops += ForLoops |
ifElseStatements += IfElseStatements
)
;
// IfElse Statements requiring if statements and optionally followed by
// one else statement.
IfElseStatements:
ifStatements += IfStatements
(elseStatement = ElseStatement)?
;
// If statements requiring conditions and optionally followed by
// library functions or for loops.
IfStatements:
'if'
conditions = Conditions
(ifFunctions += libraryFunctionsEnum | forLoops += ForLoops)
;
// Else statement requiring one or multiple library functions.
ElseStatement:
'else' elseFunctions += libraryFunctionsEnum
;
// For loops requiring one condition and followed by zero or more
// library functions
ForLoops:
'for'
conditions = Conditions
libraryFunctions += libraryFunctionsEnum*
;
//*Eventually filled with details from class diagram, but for now we manually fill it for the sake of testing.
enum libraryFunctionsEnum:
createAccount='createInstance'|
login='login'|
hasCode= 'encrypt'|
display='display'
;
Conditions:
STRING
operator=logicalOperators
STRING
;
enum logicalOperators:
greaterThan='>'|
smallerThan='<'|
greaterOrEqualThan='=>'|
smallerOrEqualThan='<='|
equalTo='=='
;
[Updated on: Wed, 08 May 2019 12:24] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.01885 seconds