org.modelcc.language.syntax.RuleSymbol 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.syntax;
import java.io.Serializable;
import org.modelcc.language.metamodel.LanguageMember;
/**
* Rule symbol.
*
* @author Luis Quesada ([email protected]) & Fernando Berzal ([email protected])
*/
public class RuleSymbol implements Serializable
{
/**
* Rule symbol type.
*/
private Object type;
/**
* Language member.
*/
private LanguageMember member;
/**
* Constructor.
* @param type the type of the rule symbol.
*/
public RuleSymbol (Object type)
{
this.type = type;
}
/**
* Constructor.
* @param type the type of the rule symbol.
* @param member the language member.
*/
public RuleSymbol (Object type, LanguageMember member)
{
this.type = type;
this.member = member;
}
/**
* Get rule symbol type
* @return the type of the rule symbol
*/
public Object getType()
{
return type;
}
/**
* Get symbol position
* @return the symbol position
*/
public LanguageMember getLanguageMember()
{
return member;
}
// Object methods
@Override
public int hashCode()
{
return ((type == null) ? 0 : type.hashCode());
}
@Override
public boolean equals (Object obj)
{
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
RuleSymbol other = (RuleSymbol) obj;
if ((type==null) && (other.type!=null))
return false;
else if (!type.equals(other.type))
return false;
return true;
}
}