mirror of
https://github.com/AppleCommander/bastools.git
synced 2025-04-09 18:38:43 +00:00
Initial REM removal. Have yet to fix up line numbers that go away.
This commit is contained in:
parent
ed6227bb97
commit
411748ad52
@ -4,6 +4,7 @@ import com.webcodepro.applecommander.util.applesoft.Line;
|
||||
import com.webcodepro.applecommander.util.applesoft.Program;
|
||||
import com.webcodepro.applecommander.util.applesoft.Statement;
|
||||
import com.webcodepro.applecommander.util.applesoft.Token;
|
||||
import com.webcodepro.applecommander.util.applesoft.Token.Type;
|
||||
import com.webcodepro.applecommander.util.applesoft.Visitor;
|
||||
|
||||
import picocli.CommandLine.ITypeConverter;
|
||||
@ -14,6 +15,12 @@ public enum Optimization {
|
||||
public Statement visit(Statement statement) {
|
||||
return statement.tokens.isEmpty() ? null : statement;
|
||||
}
|
||||
}),
|
||||
REMOVE_REM_STATEMENTS(new BaseVisitor() {
|
||||
@Override
|
||||
public Statement visit(Statement statement) {
|
||||
return statement.tokens.get(0).type == Type.COMMENT ? null : statement;
|
||||
}
|
||||
})
|
||||
;
|
||||
|
||||
@ -47,7 +54,7 @@ public enum Optimization {
|
||||
Program newProgram = new Program();
|
||||
program.lines.forEach(l -> {
|
||||
Line line = l.accept(this);
|
||||
if (line != null) newProgram.lines.add(line);
|
||||
if (line != null && !line.statements.isEmpty()) newProgram.lines.add(line);
|
||||
});
|
||||
return newProgram;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user