xtext - Including a grammar into another grammar -


i reuse grammar definitions.

i have grammar this:

person:   'contact' name=id '{'     'phone' phone=int   '}' ; 

i have grammar this:

include "uri/to/other/project/to/other/grammar/definitions"  call:   'call' person=person ; 

person not known second grammar. xtext therefore able insert or include person definition first grammar second grammar?

a further step generation of person. know how accomplish too.

i found solution. can use keyword "with" used include terminals.

the necessary steps:

  1. create xtext project com.mydsl.a (a) , com.mydsl.b (b)
  2. write grammar a
  3. add dependency in meta-inf/manifest of b
  4. add a.ui dependency in meta-inf/manifest of b.ui
  5. add registration of a's genmodel in b's workflow that: in standalonesetup: registergenmodelfile = "platform:/resource/a/src-gen/path/to/a.genmodel"
  6. change first line of b grammar b a
  7. you can use eclasses of while writing grammar b

with cannot used include more 1 grammar, terminal definitions must stated in a.

the generation executed in b's igenerator, can reuse generation of a's eclasses if extend a's generator.

this approach kind of inheritance, since proposal, validation, etc classes extended a's counterparts. didn't find out if multiple inheritance supported. can place comma after with a doesn't work.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -