Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Best practice
Best practice [message #1027781] Wed, 27 March 2013 12:03
Stefano Cottafavi is currently offline Stefano CottafaviFriend
Messages: 57
Registered: July 2009
Member
Hi,
this is very basic question about best practice developing a DSL editor.
I've to create an editor for a given "properties file"; its content could be resumed with this scheme

valA keyA -optionalcomment
valB keyB -optionalcomment
....
valZ keyZ -optionalcomment


the file has a fixed structure:
- "keys" must appear in specific row, no key-row can be left out
- "values" can be bool,num(int or float),string, or array of them (again I know exactly which will be bools and where strings due to the fixed structure)
- "spaces" are important in this case (as in CSV files). space (or tab) separates key from value and value from optional comment

My xtext looks like this

Model:
pair1 = VarBOOL
pair2 = VarNUM
pair3 = VarNUM
pair4 = VarSTRING
pair5 = VarSTRING
...

VarBOOL hidden(NEWLINE,SL_COMMENT):
value=BOOL WS key=NAME WS;
VarNUM hidden(NEWLINE,SL_COMMENT):
value=NUMBER WS key=NAME WS;
VarSTRING hidden(NEWLINE,SL_COMMENT):
value=STRING WS key=NAME WS;

in the terminals I've separated WS from NEWLINE.

the grammar compiles fine, the scheme adopted allow to keep the grammar quite conscise (except for the fact that the property files has more that 50 rows)
the editor generated is used in a MPE along with a form editor.

so I'm asking here if this is good to go or if, looking forward (contentproposal, quickfix, outline), could be better to make the key actual "keywords" as they really are for example like "key1"|"key2"|...

how this will affect the resulting model?


thank you for your time


cheers
stefano

Previous Topic:Conflicting content assist handlers
Next Topic:Exception: org.eclipse.xtext.junit.serializer.SerializerTester.serialize(SerializerTester.java:234)
Goto Forum:
  


Current Time: Fri Apr 26 19:57:03 GMT 2024

Powered by FUDForum. Page generated in 0.03057 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top