1 17 18 package org.sablecc.sablecc.exception; 19 20 import org.sablecc.sablecc.syntax3.node.Token; 21 22 public class SemanticException 23 extends Exception { 24 25 private static final long serialVersionUID = 155544165804671040L; 26 27 private Token token; 28 29 public SemanticException( 30 String message, 31 Token token) { 32 33 super("[" + token.getLine() + "," + token.getPos() + "] " + message); 34 35 if (message == null) { 36 throw new InternalException("message may not be null"); 37 } 38 39 if (token == null) { 40 throw new InternalException("token may not be null"); 41 } 42 43 this.token = token; 44 } 45 46 public SemanticException( 47 String message, 48 Token token, 49 Throwable cause) { 50 51 super("[" + token.getLine() + "," + token.getPos() + "] " + message, 52 cause); 53 54 if (message == null) { 55 throw new InternalException("message may not be null"); 56 } 57 58 if (token == null) { 59 throw new InternalException("token may not be null"); 60 } 61 62 if (cause == null) { 63 throw new InternalException("cause may not be null"); 64 } 65 66 this.token = token; 67 } 68 69 public Token getToken() { 70 71 return this.token; 72 } 73 } 74 | Popular Tags |