In my grammar I want atmost one command per line (I dont want ';' or ':' to terminate my commands). But when I use ('\r'?'\n') to ensure one command per line, it produces an extra line gape. for example it produces:
read Ram 03DF
write Ram 05FF
JMP Add 056A
CHK Reg 08AA
this is not required. Expected should be without extra line wrap. For example:
read Ram 03DF
write Ram 05FF
JMP Add 056A
CHK Reg 08AA
the overview of what I am doing is
Model:
(content += Elements ('\r'?'\n') )+
;
Elements:
Data | Path | Ram | Address
;
.
.
.
I am not sure how can I achieve that: Please help. thanks
I think you should not model new lines in the grammar since it has no influence on the semantics! But in case of pretty printing a line break makes sense after each element. Your grammar fragment should look like this:
What you are looking for is the
org.your.dsl.formatting.YourDslFormatter
class. It provides a method stub to implement formatting patterns for pretty printing. There you define that a line break will be inserted after eachElement
. Try to start with s.th. like this:Everytime you trigger Eclipse's autoformat (ctrl + shift + F) your code will be pretty printed in the editor.