package org.spoofax.jsglr2.parser;

public class Position {

    final public int offset, line, column;

    public Position(int offset, int line, int column) {
        this.offset = offset;
        this.line = line;
        this.column = column;
    }
    
    public Position(Position p) {
        this.offset = p.offset;
        this.line = p.line;
        this.column = p.column;
    }

    public Position nextColumn() {
        return new Position(offset + 1, line, column + 1);
    }

    public Position nextLine() {
        return new Position(offset + 1, line + 1, 1);
    }

    public String coordinatesToString() {
        return "" + line + ":" + column;
    }
    
    @Override public String toString() {
        return "l: " + line + " c: " + column + " offset: " + offset;
    }

    @Override public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + column;
        result = prime * result + line;
        result = prime * result + offset;
        return result;
    }

    @Override public boolean equals(Object obj) {
        if(this == obj)
            return true;
        if(obj == null)
            return false;
        if(getClass() != obj.getClass())
            return false;
        Position other = (Position) obj;
        if(column != other.column)
            return false;
        if(line != other.line)
            return false;
        if(offset != other.offset)
            return false;
        return true;
    }
    

}

@@ -62,47 +62,495 @@
     
-final public int offset, line, column;%0A
+/**%0A     * The offset in the input string, starts counting at 0 (consistent with Java string indexing).%0A     */%0A    final public int offset;%0A%0A    /**%0A     * The line number of the current offset, starts counting at 1 (consistent with IDE cursor position).%0A     */%0A    final public int line;%0A%0A    /**%0A     * The column number of the current offset, starts counting at 1 (consistent with IDE cursor position).%0A     */%0A    final public int column;%0A%0A    /**%0A     * Basic constructor.%0A     */
 %0A   
@@ -690,28 +690,112 @@
 lumn;%0A    %7D%0A
+%0A
     
+/**%0A     * Clones a Position.%0A     *%0A     * @param p The Position to clone.%0A     */
 %0A    public 
@@ -924,104 +924,432 @@
     
-public Position nextColumn() %7B%0A        return new Position(offset + 1, line, column + 1);%0A    %7D%0A
+/**%0A     * @return A new position that represents the position right of the current position.%0A     */%0A    public Position nextColumn() %7B%0A        return new Position(offset + 1, line, column + 1);%0A    %7D%0A%0A    /**%0A     * Should only be called when the character at the current position is a newline character.%0A     *%0A     * @return A new position that represents the first column on the line after the current position.%0A     */
 %0A   
@@ -1499,13 +1499,8 @@
 turn
- %22%22 +
  lin
@@ -1523,20 +1523,16 @@
 ;%0A    %7D%0A
-    
 %0A    @Ov
@@ -2351,16 +2351,12 @@
 ;%0A    %7D%0A
-    
 %0A%0A%7D%0A

Add documentation to Position class