<commit_before>package parse_table_generator;

/**
 *
 * @author <NAME>
 * @author <NAME>
 * @author <NAME>
 * @version Mar 14, 2016
 */
public class Item {

    //Rule rule;
    //int position;
    Terminal lookahead;

    private final Rule rule;
    private final int position;

    /**
     * Item with a lookahead symbol LR(1). 
     * @param rule the production rule.
     * @param position the position of the "cursor".
     * @param lookahead the lookahead terminal symbol.
     */
    public Item(Rule rule, int position, Terminal lookahead) {
        if (position < 0 || position > rule.rhs.size()) {
            throw new IllegalArgumentException(
                "Item: invalid rule position" + position);
        } else if (rule.rhs.isEmpty()) {
            this.rule = rule;
            this.position = 0;
        } else {
            this.rule = rule;
            this.position = position;
        }
        this.lookahead = lookahead;
    }
    
    /**
     * Item without a lookahead symbol LR(0).
     * @param rule the production rule
     * @param position the position of the "cursor".
     */
    public Item(Rule rule, int position){
        this(rule,position,null);
    }

    public Rule getRule() {
        return rule;
    }

    public int getPosition() {
        return position;
    }
    
    public Symbol getCurrentSymbol() {
        return rule.getSymbolOnRight(position);
    }
    
    /**
     * @return the next symbol in the RHS of the rule or null if at the end.
     */
    public Symbol getNextSymbol() {
        if(position + 1 >= rule.rhs.size()) {
            return null;
        }
        return rule.getSymbolOnRight(position+1);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        } else if (!(o instanceof Item)) {
            return false;
        } else {
            Item i = (Item) o;
            return this.rule.equals(i.getRule())
                    && this.position == i.getPosition()
                    && this.lookahead.equals(i.lookahead);
        }
    }

    @Override
    public int hashCode() {
        int result = 17;
        result = 31 * result + rule.hashCode();
        result = 31 * result + position;<commit_msg>Better.  We have 2 reduce-reduce conflicts.<commit_after>package parse_table_generator;

/**
 *
 * @author <NAME>
 * @author <NAME>
 * @author <NAME>
 * @version Mar 14, 2016
 */
public class Item {
    Terminal lookahead;

    private final Rule rule;
    private final int position;

    /**
     * Item with a lookahead symbol LR(1). 
     * @param rule the production rule.
     * @param position the position of the "cursor".
     * @param lookahead the lookahead terminal symbol.
     */
    public Item(Rule rule, int position, Terminal lookahead) {
        if (position < 0 || position > rule.rhs.size()) {
            throw new IllegalArgumentException(
                "Item: invalid rule position" + position);
        } else if (rule.rhs.isEmpty()) {
            this.rule = rule;
            this.position = 0;
        } else {
            this.rule = rule;
            this.position = position;
        }
        this.lookahead = lookahead;
    }
    
    /**
     * Item without a lookahead symbol LR(0).
     * @param rule the production rule
     * @param position the position of the "cursor".
     */
    public Item(Rule rule, int position){
        this(rule,position,null);
    }

    public Rule getRule() {
        return rule;
    }

    public int getPosition() {
        return position;
    }
    
    public Symbol getCurrentSymbol() {
        return rule.getSymbolOnRight(position);
    }
    
    /**
     * @return the next symbol in the RHS of the rule or null if at the end.
     */
    public Symbol getNextSymbol() {
        if(position + 1 >= rule.rhs.size()) {
            return null;
        }
        return rule.getSymbolOnRight(position+1);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        } else if (!(o instanceof Item)) {
            return false;
        } else {
            Item i = (Item) o;
            return this.rule.equals(i.getRule())
                    && this.position == i.getPosition()
                    && ((this.lookahead == null && i.lookahead == null) ||
                        (this.lookahead.equals(i.lookahead)));
        }
    }

    @Override
    public int hashCode() {
        int result = 17;
        result = 31 * result + rule.hashCode();
        result = 31 * result + position;
{'fraction_non_alphanumeric': 0.10941253548809783, 'fraction_numerical': 0.008080366892334571, 'mean_word_length': 1.7474505098980204, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '3111014', 'n_tokens_mistral': 1327, 'n_tokens_neox': 1249, 'n_words': 392}