/* This file is part of SableCC ( http://sablecc.org ).
 *
 * See the NOTICE file distributed with this work for copyright information.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.sablecc.sablecc.exception;

import org.sablecc.sablecc.syntax3.node.Token;

public class SemanticException
        extends Exception {

    private static final long serialVersionUID = 155544165804671040L;

    private Token token;

    public SemanticException(
            String message,
            Token token) {

        super("[" + token.getLine() + "," + token.getPos() + "] " + message);

        if (message == null) {
            throw new InternalException("message may not be null");
        }

        if (token == null) {
            throw new InternalException("token may not be null");
        }

        this.token = token;
    }

    public SemanticException(
            String message,
            Token token,
            Throwable cause) {

        super("[" + token.getLine() + "," + token.getPos() + "] " + message,
                cause);

        if (message == null) {
            throw new InternalException("message may not be null");
        }

        if (token == null) {
            throw new InternalException("token may not be null");
        }

        if (cause == null) {
            throw new InternalException("cause may not be null");
        }

        this.token = token;
    }

    public Token getToken() {

        return this.token;
    }
}

@@ -780,16 +780,100 @@
 Token;%0A%0A
+/**%0A * A semantic exception is thrown when a logic error is found in a grammar.%0A */%0A
 public c
@@ -920,24 +920,79 @@
 xception %7B%0A%0A
+    /** Serial version identifier for serialization */%0A
     private 
@@ -1058,29 +1058,406 @@
     
-private Token token;%0A
+/** The token of this semantic exception. */%0A    private Token token;%0A%0A    /**%0A     * Constructs a semantic exception with the provided error message and%0A     * token.%0A     * %0A     * @param message%0A     *            the error message.%0A     * @param token%0A     *            the token.%0A     * @throws InternalException%0A     *             if the provided message or token is %3Ccode%3Enull%3C/code%3E.%0A     */
 %0A   
@@ -1861,32 +1861,423 @@
 = token;%0A    %7D%0A%0A
+    /**%0A     * Constructs a semantic exception with the provided error message, token%0A     * and cause.%0A     * %0A     * @param message%0A     *            the error message.%0A     * @param token%0A     *            the token.%0A     * @param cause%0A     *            the cause.%0A     * @throws InternalException%0A     *             if the provided message, token or cause is %3Ccode%3Enull%3C/code%3E.%0A     */%0A
     public Seman
@@ -2830,24 +2830,127 @@
 ken;%0A    %7D%0A%0A
+    /**%0A     * Returns the token of this semantic exception.%0A     * %0A     * @return the token.%0A     */%0A
     public T

Add javadoc comments.