mirror of
https://github.com/irmen/prog8.git
synced 2024-12-24 01:29:28 +00:00
fix windows line ending (\r\n) parse errors
This commit is contained in:
parent
374e2b311d
commit
b4700af2f5
@ -41,8 +41,8 @@ class ModuleImporter {
|
||||
if(!Files.isReadable(filePath))
|
||||
throw ParsingFailedError("No such file: $filePath")
|
||||
|
||||
val input = CharStreams.fromPath(filePath)
|
||||
return importModule(program, input, filePath, false, encoder, compilationTargetName)
|
||||
val content = Files.readAllBytes(filePath).toString(Charsets.UTF_8).replace("\r\n", "\n")
|
||||
return importModule(program, CharStreams.fromString(content), filePath, false, encoder, compilationTargetName)
|
||||
}
|
||||
|
||||
fun importLibraryModule(program: Program, name: String,
|
||||
@ -122,7 +122,8 @@ class ModuleImporter {
|
||||
val (resource, resourcePath) = rsc
|
||||
resource.use {
|
||||
println("importing '$moduleName' (library)")
|
||||
importModule(program, CharStreams.fromStream(it), Paths.get("@embedded@/$resourcePath"),
|
||||
val content = it.readAllBytes().toString(Charsets.UTF_8).replace("\r\n", "\n")
|
||||
importModule(program, CharStreams.fromString(content), Paths.get("@embedded@/$resourcePath"),
|
||||
true, encoder, compilationTargetName)
|
||||
}
|
||||
} else {
|
||||
|
@ -5,6 +5,7 @@ NOTES:
|
||||
|
||||
- whitespace is ignored. (tabs/spaces)
|
||||
- every position can be empty, be a comment, or contain ONE statement.
|
||||
- input is assumed to be a text file with UNIX line endings (\n).
|
||||
|
||||
*/
|
||||
|
||||
@ -14,10 +15,10 @@ grammar prog8;
|
||||
package prog8.parser;
|
||||
}
|
||||
|
||||
LINECOMMENT : [\r\n][ \t]* COMMENT -> channel(HIDDEN);
|
||||
COMMENT : ';' ~[\r\n]* -> channel(HIDDEN) ;
|
||||
LINECOMMENT : [\n][ \t]* COMMENT -> channel(HIDDEN);
|
||||
COMMENT : ';' ~[\n]* -> channel(HIDDEN) ;
|
||||
WS : [ \t] -> skip ;
|
||||
EOL : [\r\n]+ ;
|
||||
EOL : [\n]+ ;
|
||||
// WS2 : '\\' EOL -> skip;
|
||||
VOID: 'void';
|
||||
NAME : [a-zA-Z][a-zA-Z0-9_]* ;
|
||||
|
Loading…
Reference in New Issue
Block a user