org.modelcc.language.factory.MemberSpecification 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.factory;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.modelcc.language.metamodel.LanguageMember;
/**
* Member specification
*
* @author Luis Quesada ([email protected]), refactored by Fernando Berzal ([email protected])
*/
public class MemberSpecification implements Serializable
{
private List members;
private Map contents;
public MemberSpecification()
{
members = new ArrayList();
contents = new HashMap();
}
public MemberSpecification(LanguageMember em)
{
this();
members.add(em);
}
public MemberSpecification(MemberSpecification mn)
{
this();
add(mn);
}
public List getMembers()
{
return members;
}
public void clear()
{
members = new ArrayList();
}
public void add(LanguageMember member)
{
members.add(member);
}
public void addAll(List newMembers)
{
members.addAll(newMembers);
}
public void add(MemberSpecification member)
{
members.addAll(member.members);
contents.putAll(member.contents);
}
public MemberContent getContent (LanguageMember member)
{
return contents.get(member);
}
public void setContent (LanguageMember member, MemberContent content)
{
contents.put(member, content);
}
public LanguageMember getFront() {
if (members.size()==0)
return null;
return members.get(0);
}
public LanguageMember getBack() {
if (members.size()==0)
return null;
return members.get(members.size()-1);
}
}