mips without optimize

This commit is contained in:
colden
2025-12-12 20:14:00 +08:00
parent 84827838e2
commit c94bebf37b
130 changed files with 5462 additions and 4182 deletions

84
frontend/lexer/Token.java Normal file → Executable file
View 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";
}
}