0
votes

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.

1

1 Answers

0
votes

You're question isn't super clear, but if what you call "POJO classes" are, or could be turned into, EMF generated code, from a "meta model" say expressed in XCore, which is a DSL for an EMF Ecore model (which you can import from an existing Java model...) then my EMF Simple Object Notation ESON (ex-EFactory) at https://github.com/vorburger/efactory could be of interest to you?