<commit_before>/* 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;
    }
}<commit_msg>Add javadoc comments. See ticket:64.<commit_after>/* 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;

/**
 * A semantic exception is thrown when a logic error is found in a grammar.
 */
public class SemanticException
        extends Exception {

    /** Serial version identifier for serialization */
    private static final long serialVersionUID = 155544165804671040L;

    /** The token of this semantic exception. */
    private Token token;

    /**
     * Constructs a semantic exception with the provided error message and
     * token.
     * 
     * @param message
     *            the error message.
     * @param token
     *            the token.
     * @throws InternalException
     *             if the provided message or token is <code>null</code>.
     */
    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;
    }

    /**
     * Constructs a semantic exception with the provided error message, token
     * and cause.
     * 
     * @param message
     *            the error message.
     * @param token
     *            the token.
     * @param cause
     *            the cause.
     * @throws InternalException
     *             if the provided message, token or cause is <code>null</code>.
     */
    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;
    }

    /**
     * Returns the token of this semantic exception.
     * 
     * @return the token.
     */
    public Token getToken() {

        return this.token;
    }
}
{'fraction_non_alphanumeric': 0.0936086529006883, 'fraction_numerical': 0.00943952802359882, 'mean_word_length': 2.0842935112189207, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5104292', 'n_tokens_mistral': 1356, 'n_tokens_neox': 1282, 'n_words': 499}