Skip to content

Commit ad38170

Browse files
committed
Fix minor issues
1 parent f970b4a commit ad38170

2 files changed

Lines changed: 7 additions & 11 deletions

File tree

src/main/resources/lexer.flex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,22 +81,22 @@ Identifier = [a-zA-Z][a-zA-Z0-9_]*
8181
"const" { return newSymbol(sym.CONST); }
8282

8383
// Operators
84-
// Arithmetic operatrors
84+
// Arithmetic operators
8585
"+" { return newSymbol(sym.PLUS); }
8686
"-" { return newSymbol(sym.MINUS); }
8787
"*" { return newSymbol(sym.TIMES); }
8888
"/" { return newSymbol(sym.DIV); }
8989
"%" { return newSymbol(sym.MOD); }
9090
"++" { return newSymbol(sym.INCR); }
9191
"--" { return newSymbol(sym.DECR); }
92-
// Relational operatrors
92+
// Relational operators
9393
"==" { return newSymbol(sym.EQ); }
9494
"!=" { return newSymbol(sym.NEQ); }
9595
"<" { return newSymbol(sym.LT); }
9696
"<=" { return newSymbol(sym.LEQ); }
9797
">" { return newSymbol(sym.GT); }
9898
">=" { return newSymbol(sym.GEQ); }
99-
// Logical operatrors
99+
// Logical operators
100100
"&&" { return newSymbol(sym.AND); }
101101
"||" { return newSymbol(sym.OR); }
102102

src/test/java/dev/askov/mjcompiler/CompilationHelper.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,6 @@ public static class SemanticResult {
7070
this.parseResult = parseResult;
7171
this.semanticError = semanticError;
7272
}
73-
74-
public boolean hasErrors() {
75-
return parseResult.hasErrors() || semanticError;
76-
}
7773
}
7874

7975
@SuppressWarnings("unchecked")
@@ -198,17 +194,17 @@ public static String compileAndRun(String source) throws Exception {
198194
return compileAndRun(source, "");
199195
}
200196

201-
public static String runVM(File objFile, String input) throws Exception {
197+
public static String runVM(File objFile, String input) {
202198
var originalIn = System.in;
203199
var originalOut = System.out;
204200
try {
205201
System.setIn(new ByteArrayInputStream(input.getBytes(StandardCharsets.UTF_8)));
206-
var baos = new ByteArrayOutputStream();
207-
System.setOut(new PrintStream(baos, true, StandardCharsets.UTF_8));
202+
var outputStream = new ByteArrayOutputStream();
203+
System.setOut(new PrintStream(outputStream, true, StandardCharsets.UTF_8));
208204

209205
Run.main(new String[] {objFile.getAbsolutePath()});
210206

211-
var output = baos.toString(StandardCharsets.UTF_8);
207+
var output = outputStream.toString(StandardCharsets.UTF_8);
212208
var completionIndex = output.indexOf("\nCompletion took");
213209
if (completionIndex >= 0) {
214210
output = output.substring(0, completionIndex);

0 commit comments

Comments
 (0)