use of org.whole.lang.grammars.model.LiteralTerminal in project whole by wholeplatform.
the class LiteralTerminalPart method getModelSpecificChildren.
protected List<IEntity> getModelSpecificChildren() {
LiteralTerminal entity = getModelEntity();
List<IEntity> list = new ArrayList<IEntity>(2);
list.add(entity.getPattern());
list.add(entity.getLiteral());
return list;
}
use of org.whole.lang.grammars.model.LiteralTerminal in project whole by wholeplatform.
the class GrammarBasedUnparserVisitor method visit.
@Override
public void visit(Grammar entity) {
LiteralTerminal lt = entity.getDelimiter();
if (EntityUtils.isNotResolver(lt))
delimiter = lt.getLiteral().getValue();
space = EntityUtils.safeStringValue(entity.getSpaceLiteral(), space);
indent = EntityUtils.safeStringValue(entity.getIndentLiteral(), indent);
newLine = EntityUtils.safeStringValue(entity.getNewLineLiteral(), newLine);
normalize(entity);
if (!appendModelEntityAsFragment())
nameProductionMap.get(model.wGetEntityDescriptor().getName()).accept(this);
if (delimited)
appendDelimiter();
}
use of org.whole.lang.grammars.model.LiteralTerminal in project whole by wholeplatform.
the class LiteralTerminalParserPart method getModelSpecificChildren.
protected List<IEntity> getModelSpecificChildren() {
LiteralTerminal entity = getModelEntity();
List<IEntity> list = new ArrayList<IEntity>(1);
list.add(entity.getPattern());
return list;
}
use of org.whole.lang.grammars.model.LiteralTerminal in project whole by wholeplatform.
the class LiteralTerminalUnparserPart method getModelSpecificChildren.
protected List<IEntity> getModelSpecificChildren() {
LiteralTerminal entity = getModelEntity();
List<IEntity> list = new ArrayList<IEntity>(1);
list.add(entity.getLiteral());
return list;
}
use of org.whole.lang.grammars.model.LiteralTerminal in project whole by wholeplatform.
the class GrammarsDefaultEntityRegistryConfiguration method apply.
public void apply(IEntityRegistry er) {
super.apply(er);
GrammarsEntityFactory ef = GrammarsEntityFactory.instance(er);
RegExp regex;
Literal literal;
IdentityEventHandler deriveLiteralPattern = new IdentityEventHandler() {
private static final long serialVersionUID = 1L;
private String derivedPattern;
@Override
public void notifyChanged(IEntity source, FeatureDescriptor featureDesc, String oldValue, String newValue) {
IEntity parent = source.wGetParent();
if (parent instanceof LiteralTerminal) {
LiteralTerminal literalTerminal = (LiteralTerminal) parent;
Literal literal = literalTerminal.getLiteral();
if (literal == source) {
derivedPattern = StringUtils.quoteRegex(newValue);
literalTerminal.getPattern().wSetValue(derivedPattern);
} else if (newValue != derivedPattern) {
source.wRemoveChangeEventHandler(this);
literal.wRemoveChangeEventHandler(this);
}
}
}
};
er.put(ef.createEmpty(ef.createLiteral("")));
er.put(ef.createChoose(2));
er.put(ef.createConcatenate(2));
er.put(ef.createLiteralTerminal(regex = ef.createRegExp("pattern"), ef.createCategory(CategoryEnum.DELIMITER), literal = ef.createLiteral("literal")));
regex.wAddChangeEventHandler(deriveLiteralPattern);
literal.wAddChangeEventHandler(deriveLiteralPattern);
er.put(ef.createDataTerminal(ef.createRegExp(".*"), ef.createCategory(CategoryEnum.LITERAL), ef.createFormat("%s")));
er.put(ef.createAs(ef.createNonTerminal("nt"), ef.createName("name")));
er.put(ef.createByLines(1));
er.put(ef.createBySize(10));
er.put(ef.createRepeat(ef.createSize(0), ef.createUnbounded(), ef.buildLiteralTerminal().set(GrammarsFeatureDescriptorEnum.literal, ",").getResult(), createResolver(GrammarsEntityDescriptorEnum.Rule)));
er.put(ef.createBySize(5));
er.put(ef.createGrammar(ef.createName("GrammarName"), createResolver(GrammarsEntityDescriptorEnum.TargetLanguage), createResolver(GrammarsEntityDescriptorEnum.NonTerminal), ef.createLiteralTerminal(ef.createRegExp("\\p{javaWhitespace}*"), ef.createCategory(CategoryEnum.SEPARATOR), ef.createLiteral("")), ef.createProductions(0), ef.createProductions(ef.create(GrammarsEntityDescriptorEnum.Production, ef.createNonTerminal("StartSymbol"), createResolver(GrammarsEntityDescriptorEnum.Rule))), // ef.createNamespace("org.whole.examples.grammarname"),
createResolver(GrammarsEntityDescriptorEnum.URI), createResolver(GrammarsEntityDescriptorEnum.Namespace), createResolver(GrammarsEntityDescriptorEnum.Version), createResolver(GrammarsEntityDescriptorEnum.Literal), createResolver(GrammarsEntityDescriptorEnum.Literal), createResolver(GrammarsEntityDescriptorEnum.Literal)));
}
Aggregations