noviablealtexception.java

来自「SRI international 发布的OAA框架软件」· Java 代码 · 共 63 行

JAVA
63
字号
package antlr_oaa;

/* ANTLR Translator Generator
 * Project led by Terence Parr at http://www.jGuru.com
 * Software rights: http://www.antlr.org/RIGHTS.html
 *
 * $Id: NoViableAltException.java,v 1.1 2002/11/08 17:37:51 agno Exp $
 */

import antlr_oaa.collections.AST;

public class NoViableAltException extends RecognitionException {
	public Token token;
	public AST node;	// handles parsing and treeparsing

	public NoViableAltException(AST t) {
		super("NoViableAlt");
		node = t;
		fileName = "<AST>";
	}

	public NoViableAltException(Token t, String fileName) {
		super("NoViableAlt");
		token = t;
		line = t.getLine();
		column = t.getColumn();
		this.fileName = fileName;
	}

	/**
	 * @deprecated As of ANTLR 2.7.0
	 */
	public String getErrorMessage () {
		return getMessage();
	}

	/**
	 * Returns a clean error message (no line number/column information)
	 */
	public String getMessage ()
	{
		if (token != null) {
			return "unexpected token: "+token.getText();
		}

		// must a tree parser error if token==null
		if ( node==TreeParser.ASTNULL ) {
			return "unexpected end of subtree";
		}
		return "unexpected AST node: "+node.toString();
	}

    /**
     * Returns a string representation of this exception.
     */
    public String toString() {
	if ( token!=null ) { // AST or Token?
	    return FileLineFormatter.getFormatter().getFormatString(fileName,line)+getMessage();
	}
	return getMessage();
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?