|
@@ -1,30 +1,29 @@
|
|
|
package de.jplag;
|
|
package de.jplag;
|
|
|
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * This class represents a token in a source code. It can represents keywords, identifies, syntactical structures etc.
|
|
|
|
|
+ * What types of tokens there are depends on the specific language, meaning JPlag does not enforce a specific token set.
|
|
|
|
|
+ * The language parsers decide what is a token and what is not.
|
|
|
|
|
+ */
|
|
|
public abstract class Token {
|
|
public abstract class Token {
|
|
|
private boolean basecode = false;
|
|
private boolean basecode = false;
|
|
|
private String file;
|
|
private String file;
|
|
|
private int hash = -1;// hash-value. set and used by main algorithm (GSTiling)
|
|
private int hash = -1;// hash-value. set and used by main algorithm (GSTiling)
|
|
|
private boolean marked;
|
|
private boolean marked;
|
|
|
|
|
|
|
|
- protected int column;
|
|
|
|
|
- protected int length;
|
|
|
|
|
- protected int line;
|
|
|
|
|
|
|
+ private int line;
|
|
|
protected int type;
|
|
protected int type;
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Creates a token without information about the column or the length of the token in the line.
|
|
|
|
|
+ * @param type is the token type.
|
|
|
|
|
+ * @param file is the name of the source code file.
|
|
|
|
|
+ * @param line is the line in the source code where the token resides. Cannot be smaller than 1.
|
|
|
|
|
+ */
|
|
|
public Token(int type, String file, int line) {
|
|
public Token(int type, String file, int line) {
|
|
|
- this(type, file, line, -1, -1);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public Token(int type, String file, int line, int column, int length) {
|
|
|
|
|
this.type = type;
|
|
this.type = type;
|
|
|
this.file = file;
|
|
this.file = file;
|
|
|
setLine(line > 0 ? line : 1);
|
|
setLine(line > 0 ? line : 1);
|
|
|
- setColumn(column);
|
|
|
|
|
- setLength(length);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public int getColumn() {
|
|
|
|
|
- return column;
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public String getFile() {
|
|
public String getFile() {
|
|
@@ -40,28 +39,24 @@ public abstract class Token {
|
|
|
return -1;
|
|
return -1;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public int getLength() {
|
|
|
|
|
- return length;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
public int getLine() {
|
|
public int getLine() {
|
|
|
return line;
|
|
return line;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public boolean isBasecode() {
|
|
|
|
|
- return basecode;
|
|
|
|
|
|
|
+ public int getColumn() {
|
|
|
|
|
+ return 0; // no column
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public boolean isMarked() {
|
|
|
|
|
- return marked;
|
|
|
|
|
|
|
+ public int getLength() {
|
|
|
|
|
+ return 0; // no length
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public void setColumn(int column) {
|
|
|
|
|
- this.column = column;
|
|
|
|
|
|
|
+ public boolean isBasecode() {
|
|
|
|
|
+ return basecode;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public void setLength(int length) {
|
|
|
|
|
- this.length = length;
|
|
|
|
|
|
|
+ public boolean isMarked() {
|
|
|
|
|
+ return marked;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public void setLine(int line) {
|
|
public void setLine(int line) {
|