use of org.whole.lang.grammars.model.LanguageDescriptor in project whole by wholeplatform.
the class LanguageDescriptorPart method getModelSpecificChildren.
protected List<IEntity> getModelSpecificChildren() {
LanguageDescriptor entity = getModelEntity();
List<IEntity> list = new ArrayList<IEntity>(4);
list.add(entity.getUri());
list.add(entity.getNamespace());
list.add(entity.getName());
list.add(entity.getVersion());
return list;
}
use of org.whole.lang.grammars.model.LanguageDescriptor in project whole by wholeplatform.
the class GrammarsInterpreterVisitor method visit.
@Override
public void visit(Grammar grammar) {
grammar = normalize(grammar);
GrammarsRegistry.instance().putGrammar(grammar);
TargetLanguage targetLanguage = grammar.getTargetLanguage();
ILanguageKit languageKit = null;
final String languageUri;
IBindingManager bm = getBindings();
if (Matcher.match(GrammarsEntityDescriptorEnum.URI, targetLanguage)) {
languageUri = targetLanguage.wStringValue();
languageKit = ReflectionFactory.getLanguageKit(languageUri, true, bm);
} else {
languageUri = ((LanguageDescriptor) targetLanguage).getUri().getValue();
stagedVisit(GrammarsUtils.deriveModel(grammar, false));
languageKit = (ILanguageKit) bm.getResult().wGetValue();
}
if (languageKit.isDynamic()) {
DynamicLanguageKit dynamicLanguageKit = (DynamicLanguageKit) languageKit;
GrammarBasedDataTypeParser dataTypeParser = new GrammarBasedDataTypeParser(grammar.getUri().getValue());
dynamicLanguageKit.setDataTypeParser(DataTypeParsers.PERSISTENCE, dataTypeParser);
dynamicLanguageKit.setDataTypeParser(DataTypeParsers.PRESENTATION, dataTypeParser);
}
ReflectionFactory.updatePersistenceAndEditorKits(languageKit);
ReflectionFactory.deploy(new AbstractLanguageExtensionDeployer() {
public void deploy(ReflectionFactory platform) {
platform.addOperationFactory(languageUri, PrettyPrinterOperation.ID, new IVisitorFactory() {
public IVisitor create(IOperation operation, int stage) {
return new GenericGrammarBasedPrettyPrinterVisitor((PrettyPrinterOperation) operation);
}
});
platform.addOperationFactory(languageUri, ValidatorOperation.ID, new IVisitorFactory() {
public IVisitor create(IOperation operation, int stage) {
return new GenericGrammarBasedValidatorVisitor();
}
});
}
});
}
use of org.whole.lang.grammars.model.LanguageDescriptor in project whole by wholeplatform.
the class Grammars2ModelsVisitor method visit.
@Override
public void visit(Grammar entity) {
entity = normalize(entity);
IEntityIterator<Production> lexiconIiterator = IteratorFactory.<Production>childIterator();
lexiconIiterator.reset(entity.getLexicalStructure());
for (Production p : lexiconIiterator) lexiconMap.put(p.getName().getValue(), p);
LanguageDescriptor ld = (LanguageDescriptor) entity.getTargetLanguage();
ModelsEntityFactory mf = ModelsEntityFactory.instance;
Model model = mf.createModel(mf.createSimpleName(ld.getName().getValue()), mf.createTypeRelations(), modelDeclarations = mf.createModelDeclarations(), mf.createNamespace(ld.getNamespace().getValue()), EntityUtils.isResolver(ld.getVersion()) ? CommonsEntityAdapterFactory.createResolver(ModelsEntityDescriptorEnum.Version) : mf.createVersion(ld.getVersion().getValue()), mf.createURI(ld.getUri().getValue()));
entity.getPhraseStructure().accept(this);
setResult(model);
}
use of org.whole.lang.grammars.model.LanguageDescriptor in project whole by wholeplatform.
the class AbstractGrammarSpecificPersistenceKit method removeLanguageDescriptor.
public static Grammar removeLanguageDescriptor(Grammar grammar) {
TargetLanguage targetLanguage = grammar.getTargetLanguage();
if (Matcher.match(GrammarsEntityDescriptorEnum.URI, targetLanguage))
return grammar;
grammar.setTargetLanguage(EntityUtils.remove(((LanguageDescriptor) targetLanguage).getUri()));
return grammar;
}
Aggregations