Skip to content

Commit 0421fd5

Browse files
committed
Internal linter mode for unit tests
1 parent 40294b5 commit 0421fd5

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

ownlang-parser/src/main/java/com/annimon/ownlang/parser/linters/LinterStage.java

+7-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import java.util.List;
1313

1414
public class LinterStage implements Stage<Node, Node> {
15-
public enum Mode { NONE, SEMANTIC, FULL }
15+
public enum Mode { NONE, INTERNAL, SEMANTIC, FULL }
1616

1717
private final Mode mode;
1818

@@ -29,10 +29,14 @@ public Node perform(StagesData stagesData, Node input) {
2929
validators.add(new IncludeSourceValidator(results));
3030
validators.add(new LoopStatementsValidator(results));
3131

32-
if (mode == Mode.SEMANTIC) {
32+
if (mode == Mode.SEMANTIC || mode == Mode.INTERNAL) {
3333
validators.forEach(input::accept);
3434
if (results.hasErrors()) {
35-
throw new OwnLangParserException(results.errors().toList());
35+
if (mode == Mode.INTERNAL) {
36+
System.err.println(results.errors().toList());
37+
} else {
38+
throw new OwnLangParserException(results.errors().toList());
39+
}
3640
}
3741
return input;
3842
}

ownlang-parser/src/test/java/com/annimon/ownlang/parser/ProgramsTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public static void createStage() {
3838
testPipeline = new SourceLoaderStage()
3939
.then(new LexerStage())
4040
.then(new ParserStage())
41-
.then(new LinterStage(LinterStage.Mode.SEMANTIC))
41+
.then(new LinterStage(LinterStage.Mode.INTERNAL))
4242
.thenConditional(true, new OptimizationStage(9))
4343
.then(new MockOUnitStage())
4444
.then(new ExecutionStage())

0 commit comments

Comments
 (0)