diff --git a/compilerAst/src/prog8/parser/ModuleParsing.kt b/compilerAst/src/prog8/parser/ModuleParsing.kt index 4c0b0a8ef..630c40b90 100644 --- a/compilerAst/src/prog8/parser/ModuleParsing.kt +++ b/compilerAst/src/prog8/parser/ModuleParsing.kt @@ -45,8 +45,6 @@ class ModuleImporter(private val program: Program, throw ParsingFailedError("No such file: $filePath") var content = filePath.toFile().readText().replace("\r\n", "\n") // normalize line endings - if(content.last()!='\n') - content+='\n' // grammar requires blocks (and thus module files) to end in an EOL return importModule(CharStreams.fromString(content), filePath, false) } diff --git a/parser/antlr/prog8.g4 b/parser/antlr/prog8.g4 index ba017e72b..e515ba161 100644 --- a/parser/antlr/prog8.g4 +++ b/parser/antlr/prog8.g4 @@ -75,7 +75,7 @@ register: 'A' | 'X' | 'Y' | 'AX' | 'AY' | 'XY' | 'Pc' | 'Pz' | 'Pn' | 'Pv' | 'R0 module : (directive | block | EOL)* EOF ; -block: identifier integerliteral? '{' EOL (block_statement | EOL) * '}' EOL ; +block: identifier integerliteral? '{' EOL (block_statement | EOL) * '}' (EOL | EOF) ; block_statement: