I'm creating a DSL with Xtext which will be used for generating images. However because I'm completely unknown to Xtext, I'm stumbling upon some problems and I hope you can give me some guidance.
Eventually I want the user to use the following coding structure:
bgcolor: ffffff
bgsize: 500x500
box1:
bgcolor: 000000
size: 300x300
position: 100x100
box2:
bgcolor: eeeeee
size: 300x300
position: 100x100
What I came up with in Xtext is the following (I did not change anything to the MWE2):
Image : (ImageElement+=ImageElementType)*;
ImageElementType: BgColor | BgSize | Box;
// SET BASIC TERMINAL RULES
terminal SIZE : INT 'x' INT;
terminal COLOR : COLOR_BASIC | COLOR_HEX;
terminal COLOR_BASIC : 'green' | 'red' | 'blue' | 'yellow' | 'black' | 'white' | 'orange' | 'purple' | 'pink';
terminal DIGIT : ('0'..'9'|'a'..'f'|'A'..'F');
terminal COLOR_HEX : DIGIT DIGIT DIGIT DIGIT DIGIT DIGIT;
BgColor: name='bgcolor:' value=COLOR;
BgSize: name='bgsize:' value=SIZE;
Box: name='box:';
There are a couple of issues I need to solve but I would like to know what the best approach is to these issues.
- How can I set boundaries to the INT's used in terminal rule SIZE.
- How can I set that bgcolor: or bgsize: may only be used once?
- How can I set that box1, box2, etc is constructed from the same rule Box:?
- How can I set that the properties specified under box1: belong to that box?
- How can I make indents mandatory?
I'm not seeking for a direct solution (would be great though ;-) ) but just some tips how to tackle these issues. Are all of these solved by editing the MWE2 workflow? I have some hard time with the documentation of Xtext.
Thanks in advance for your time and comments!
Kind regards