All Downloads are FREE. Search and download functionalities are using the official Maven repository.

aima.core.logic.common.ParserException Maven / Gradle / Ivy

package aima.core.logic.common;

import java.util.ArrayList;
import java.util.List;

/**
 * A runtime exception to be used to describe Parser exceptions. In particular
 * it provides information to help in identifying which tokens proved
 * problematic in the parse.
 * 
 * @author Ciaran O'Reilly
 * 
 */
public class ParserException extends RuntimeException {
	private static final long serialVersionUID = 1L;

	private List problematicTokens = new ArrayList();

	public ParserException(String message, Token... problematicTokens) {
		super(message);
		if (problematicTokens != null) {
			for (Token pt : problematicTokens) {
				this.problematicTokens.add(pt);
			}
		}
	}

	public ParserException(String message, Throwable cause, Token... problematicTokens) {
		super(message, cause);
		if (problematicTokens != null) {
			for (Token pt : problematicTokens) {
				this.problematicTokens.add(pt);
			}
		}
	}

	/**
	 * 
	 * @return a list of 0 or more tokens from the input stream that are
	 *         believed to have contributed to the parse exception.
	 */
	public List getProblematicTokens() {
		return problematicTokens;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy