allow correct parsing of source files that don't end in a EOL character. Fixes #40

This commit is contained in:
Irmen de Jong 2021-05-14 17:14:44 +02:00
parent b9bd541532
commit ae5d7705bb
2 changed files with 7 additions and 3 deletions

View File

@ -44,7 +44,10 @@ class ModuleImporter(private val program: Program,
if(!Files.isReadable(filePath))
throw ParsingFailedError("No such file: $filePath")
val content = filePath.toFile().readText().replace("\r\n", "\n")
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)
}

View File

@ -4,8 +4,9 @@ TODO
- possible idea: option to mark vardecls 'shared' to indicate they should not be optimized away because they're shared with assembly code?
However: who even needs variables declared in prog8 code that are only used by assembly???
- github issue: make strings no longer immutable? Deduplication selectable via command line switch?
IMPROVE DOCUMENTATION ABOUT STRINGS AND DEDUP.
- github issue about strings and their immutability:
StatementOptimizer line 60: only optimize when it's a known constant literal
IMPROVE DOCUMENTATION ABOUT STRINGS AND DEDUP and (NON)IMMUTABILITY.
- test all examples before release of the new version