içine bir DSL senaryoyu ayrıştırmak Xtext.programlı bir Ecore modeli
Ben Xtext ayrıca ayrıştırıcı uygulayan Java sınıfları oluşturmak biliyorum ama ya nerede ve nasıl kullanılacağını bilmiyorum.
@Inject
ParseHelper<Domainmodel> parser
def void parseDomainmodel() {
// When in a vanilla Java application (i.e. not within Eclipse),
// you need to run a global setup:
val injector = new MyDslStandaloneSetup().createInjectorAndDoEMFRegistration
injector.injectMembers(this) // sets the field 'parser'
// this is how you can use it:
val model = parser.parse(
"entity MyEntity {
parent: MyEntity
}")
val entity = model.elements.head as Entity
assertSame(entity, entity.features.head.type)
}
da http://www.eclipse.org/Xtext/documentation.html#TutorialUnitTests bakınız: