use of org.whole.lang.grammars.model.TargetLanguage in project whole by wholeplatform.
the class GrammarsJavaModelGeneratorVisitor method visit.
@Override
public void visit(Grammar entity) {
TargetLanguage targetLanguage = entity.getTargetLanguage();
if (Matcher.match(GrammarsEntityDescriptorEnum.LanguageDescriptor, targetLanguage)) {
Model targetModel = GrammarsUtils.deriveModel(entity, true);
stagedVisit(targetModel);
}
}
use of org.whole.lang.grammars.model.TargetLanguage 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.TargetLanguage 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