org.modelcc.language.metamodel.CompositeLanguageElement Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ModelCC Show documentation
Show all versions of ModelCC Show documentation
ModelCC is a model-based parser generator (a.k.a. compiler compiler) that decouples language specification from language processing, avoiding some of the problems caused by grammar-driven parser generators. ModelCC receives a conceptual model as input, along with constraints that annotate it. It is then able to create a parser for the desired textual language and the generated parser fully automates the instantiation of the language conceptual model. ModelCC also includes a built-in reference resolution mechanism that results in abstract syntax graphs, rather than mere abstract syntax trees.
The newest version!
/*
* ModelCC, distributed under ModelCC Shared Software License, www.modelcc.org
*/
package org.modelcc.language.metamodel;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.modelcc.AssociativityType;
import org.modelcc.CompositionType;
import org.modelcc.lexer.recognizer.PatternRecognizer;
import org.modelcc.metamodel.Evaluator;
/**
* Composite language element.
*
* @author Luis Quesada ([email protected]) & Fernando Berzal ([email protected])
*/
public final class CompositeLanguageElement extends LanguageElement
{
/**
* Key members.
*/
private List keyMembers;
/**
* Whether the members can be placed in any order.
*/
private boolean freeOrder;
/**
* Composition type.
*/
private CompositionType composition;
/**
* Field to ElementMember.
*/
private Map fieldToContent;
/**
* Constructor.
* @param elementClass the element class
* @param associativity the associativity
* @param prefix the prefix
* @param suffix the suffix
* @param separator the default separator
* @param setupMethod the setup method
* @param constraintMethods the constraint checking methods
* @param members the element contents
* @param keyMembers the element ids
* @param freeOrder whether the element members can be placed in free order
* @param composition the composition type
* @param evaluator the evaluator
*/
public CompositeLanguageElement(
Class elementClass,
AssociativityType associativity,
List prefix,
List suffix,
List separator,
String setupMethod,
List constraintMethods,
List members,
List keyMembers,
boolean freeOrder,
CompositionType composition,
Evaluator evaluator )
{
super(elementClass,associativity,prefix,suffix,separator,setupMethod,constraintMethods,evaluator);
setMembers(members);
this.keyMembers = keyMembers;
this.freeOrder = freeOrder;
this.composition = composition;
this.fieldToContent = new HashMap();
for (LanguageMember ct: members)
fieldToContent.put(ct.getID(),ct);
}
// Getters
public List getKeyMembers() {
return Collections.unmodifiableList(keyMembers);
}
public Map getFieldToContent() {
return Collections.unmodifiableMap(fieldToContent);
}
// Order
public boolean isFreeOrder() {
return freeOrder;
}
public void setFreeOrder(boolean freeOrder) {
this.freeOrder = freeOrder;
}
// Composition
public CompositionType getComposition() {
return composition;
}
public void setComposition(CompositionType composition) {
this.composition = composition;
}
}