01: /**
02: *
03: * Copyright 2004 James Strachan
04: *
05: * Licensed under the Apache License, Version 2.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: **/package org.codehaus.groovy.antlr;
18:
19: import antlr.collections.AST;
20:
21: /**
22: * @author <a href="mailto:jstrachan@protique.com">James Strachan</a>
23: * @version $Revision: 1916 $
24: */
25: public class ASTRuntimeException extends RuntimeException {
26: private AST ast;
27:
28: public ASTRuntimeException(AST ast, String message) {
29: super (message + description(ast));
30: this .ast = ast;
31: }
32:
33: public ASTRuntimeException(AST ast, String message,
34: Throwable throwable) {
35: super (message + description(ast), throwable);
36: }
37:
38: protected static String description(AST node) {
39: return (node != null) ? " at line: " + node.getLine()
40: + " column: " + node.getColumn() : "";
41: }
42:
43: public AST getAst() {
44: return ast;
45: }
46:
47: public int getLine() {
48: return ast != null ? ast.getLine() : -1;
49: }
50:
51: public int getColumn() {
52: return ast != null ? ast.getColumn() : -1;
53: }
54:
55: }
|