mips without optimize
This commit is contained in:
84
frontend/lexer/Token.java
Normal file → Executable file
84
frontend/lexer/Token.java
Normal file → Executable file
@@ -1,42 +1,42 @@
|
||||
package frontend.lexer;
|
||||
|
||||
public class Token {
|
||||
private TokenType type;
|
||||
private String value;
|
||||
private int line;
|
||||
|
||||
public Token(String value, int line) {
|
||||
this.value = value;
|
||||
this.type = TokenType.isWhatType(value);
|
||||
this.line = line;
|
||||
}
|
||||
|
||||
public void adjustType() {
|
||||
if (this.type == TokenType.IDENFR) {
|
||||
if (this.value.charAt(0) == '\"' &&
|
||||
this.value.charAt(this.value.length() - 1) == '\"') {
|
||||
this.type = TokenType.STRCON;
|
||||
}
|
||||
String regex = "^\\d+$";
|
||||
if (this.value.matches(regex)) {
|
||||
this.type = TokenType.INTCON;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public TokenType getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public int getLine() {
|
||||
return this.line;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return this.type + " " + this.value + "\n";
|
||||
}
|
||||
}
|
||||
package frontend.lexer;
|
||||
|
||||
public class Token {
|
||||
private TokenType type;
|
||||
private String value;
|
||||
private int line;
|
||||
|
||||
public Token(String value, int line) {
|
||||
this.value = value;
|
||||
this.type = TokenType.isWhatType(value);
|
||||
this.line = line;
|
||||
}
|
||||
|
||||
public void adjustType() {
|
||||
if (this.type == TokenType.IDENFR) {
|
||||
if (this.value.charAt(0) == '\"' &&
|
||||
this.value.charAt(this.value.length() - 1) == '\"') {
|
||||
this.type = TokenType.STRCON;
|
||||
}
|
||||
String regex = "^\\d+$";
|
||||
if (this.value.matches(regex)) {
|
||||
this.type = TokenType.INTCON;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public TokenType getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public int getLine() {
|
||||
return this.line;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return this.type + " " + this.value + "\n";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user