I have a requrement like this to be developed with XText
I have set of POJO classes like, (couldnt draw a diagram for this, hope this is clear enf)
( A_POJO ) ------- Level 1
( B_POJO extends A_POJO ) ------- Level 2
( C_POJO extends A_POJO ) ------- Level 2
( D_POJO extends C_POJO ) ------- Level 3
( E_POJO extends C_POJO ) ------- Level 3
( F_POJO extends C_POJO ) ------- Level 3
And then I will have this POJO classes in my class path of the eclipse where i developing this DSL. And my chalage is the developa grammer file looks like
(B_POJO or child class of it) name=ID {
[
(C_POJO or child class of it) name=ID {Attribute of (C_POJO)}
(C_POJO or child class of it) name=ID {Attribute of (C_POJO)}
(C_POJO or child class of it) name=ID {Attribute of (C_POJO)}
(C_POJO or child class of it) name=ID {Attribute of (C_POJO)}
(C_POJO or child class of it) name=ID {Attribute of (C_POJO)}
]
}
Sample will lookslike
User xx {
[
vField userName {length=25}
vField firstName {length:50}
vField otherNames {length:100}
vField password {length:25}
vField email {length:100}
]
}
Any idea is really appriciated on how to do xText grammer for this kind of dynamic work which will drive from the given POJOs.