public class VirtualLocation extends java.lang.Object implements Location
Modifier and Type | Field and Description |
---|---|
protected int |
column
The column number pertaining to the location.
|
protected java.lang.String |
fileName
The filename pertaining to the location.
|
protected int |
line
The line number pertaining to the location.
|
protected int |
tabStop
The character width of a tab in this context; defaults to 8.
|
Constructor and Description |
---|
VirtualLocation(java.lang.String fileName,
int line,
int column)
Creates a new virtual location.
|
VirtualLocation(VirtualLocation original) |
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Location l) |
Pair<java.lang.Integer,java.lang.Integer> |
countNewlines(int column,
java.lang.String lexeme)
Counts the number of newlines in a given lexeme, and the column number at the end of the lexeme.
|
void |
defaultUpdate(java.lang.String lexeme)
Performs a "default update" -- i.e., moves this virtual location
past a given lexeme.
|
void |
defaultUpdateAutomatic(java.lang.String lexeme)
This function is meant to be called automatically from
the parser.
|
int |
getColumn()
The column the parser has reached.
|
java.lang.String |
getFileName()
The name of the file being parsed.
|
java.lang.String |
getHash()
Generates and returns a string representation of the location.
|
int |
getLine()
The line the parser has reached.
|
long |
getPos()
The position in the file (makes sense only for real locations -- virtual locations should return a dummy value).
|
int |
getTabStop() |
boolean |
isModified()
Determines whether this virtual location has been modified
since its construction or its last "default update."
|
void |
setColumn(int column) |
void |
setFileName(java.lang.String fileName) |
void |
setLine(int line) |
void |
setTabStop(int tabStop) |
java.lang.String |
toString() |
protected int tabStop
protected int line
protected int column
protected java.lang.String fileName
public VirtualLocation(java.lang.String fileName, int line, int column)
fileName
- The filename pertaining to the location.line
- The line number pertaining to the location.column
- The column number pertaining to the location.public VirtualLocation(VirtualLocation original)
public int getColumn()
Location
public void setColumn(int column)
column
public java.lang.String getFileName()
Location
getFileName
in interface Location
fileName
public void setFileName(java.lang.String fileName)
fileName
public int getLine()
Location
public void setLine(int line)
line
public long getPos()
Location
public int getTabStop()
tabStop
public void setTabStop(int tabStop)
tabStop
public java.lang.String getHash()
[filename]:[line].[column]
.public boolean isModified()
defaultUpdate(String)
public void defaultUpdateAutomatic(java.lang.String lexeme)
public void defaultUpdate(java.lang.String lexeme)
lexeme
- The lexeme to move past.public java.lang.String toString()
toString
in class java.lang.Object
public int compareTo(Location l)
compareTo
in interface java.lang.Comparable<Location>
public Pair<java.lang.Integer,java.lang.Integer> countNewlines(int column, java.lang.String lexeme)
column
- The column number of the location at the beginning of the lexeme.lexeme
- The lexeme.