org.modelcc.ModelCCProcess 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;
import java.util.Collections;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.modelcc.io.log.Message;
import org.modelcc.io.log.MessageLogger;
/**
* ModelCC process
*
* @author Fernando Berzal ([email protected])
*/
public abstract class ModelCCProcess
{
/**
* Logger.
*/
private MessageLogger logger;
/**
* Log message
* @param level Warning level
* @param string Message
* @param object Message objects
*/
public final void log(Level level, String string, Object[] object)
{
if (logger==null)
logger = new MessageLogger();
logger.log(level,string,object);
Logger.getLogger(this.getClass().getName()).log(level,string,object);
}
/**
* Log message
* @param level Warning level
* @param message Exception message
* @param exception Source exception
*/
public final void log(Level level, String message, Exception exception)
{
if (logger==null)
logger = new MessageLogger();
logger.log(level,message,exception);
Logger.getLogger(this.getClass().getName()).log(level,message,exception);
}
/**
* Retrieve messages
* @return the message list
*/
public final List getMessages()
{
if (logger!=null)
return Collections.unmodifiableList(logger.getMessages());
else
return Collections.EMPTY_LIST;
}
/**
* Clear logged messages
*/
public final void clearMessages()
{
if (logger!=null)
logger.clear();
}
}