org.modelcc.parser.fence.SyntaxGraph 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.parser.fence;
import java.io.Serializable;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import org.modelcc.language.syntax.Symbol;
/**
* Syntax graph.
*
* @author Luis Quesada ([email protected])
*/
public final class SyntaxGraph implements Serializable {
/**
* Set of symbols used in this graph.
*/
private Set symbols;
/**
* Set of root symbols in this graph.
*/
private Set roots;
/**
* Default constructor.
*/
public SyntaxGraph()
{
this.symbols = new HashSet(256);
this.roots = new HashSet();
}
/**
* @return the roots symbols of this graph.
*/
public Set getRoots()
{
return Collections.unmodifiableSet(roots);
}
public void addStart (Symbol s)
{
roots.add(s);
}
/**
* @return the symbols used in this graph.
*/
public Set getSymbols()
{
return Collections.unmodifiableSet(symbols);
}
public void add (Symbol s)
{
symbols.add(s);
}
public void remove (Symbol s)
{
symbols.remove(s);
roots.remove(s);
}
}