mirror of
https://github.com/irmen/prog8.git
synced 2024-09-10 09:54:32 +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))
|
if(!Files.isReadable(filePath))
|
||||||
throw ParsingFailedError("No such file: $filePath")
|
throw ParsingFailedError("No such file: $filePath")
|
||||||
|
|
||||||
val input = CharStreams.fromPath(filePath)
|
val content = Files.readAllBytes(filePath).toString(Charsets.UTF_8).replace("\r\n", "\n")
|
||||||
return importModule(program, input, filePath, false, encoder, compilationTargetName)
|
return importModule(program, CharStreams.fromString(content), filePath, false, encoder, compilationTargetName)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun importLibraryModule(program: Program, name: String,
|
fun importLibraryModule(program: Program, name: String,
|
||||||
@ -122,7 +122,8 @@ class ModuleImporter {
|
|||||||
val (resource, resourcePath) = rsc
|
val (resource, resourcePath) = rsc
|
||||||
resource.use {
|
resource.use {
|
||||||
println("importing '$moduleName' (library)")
|
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)
|
true, encoder, compilationTargetName)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -5,6 +5,7 @@ NOTES:
|
|||||||
|
|
||||||
- whitespace is ignored. (tabs/spaces)
|
- whitespace is ignored. (tabs/spaces)
|
||||||
- every position can be empty, be a comment, or contain ONE statement.
|
- 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;
|
package prog8.parser;
|
||||||
}
|
}
|
||||||
|
|
||||||
LINECOMMENT : [\r\n][ \t]* COMMENT -> channel(HIDDEN);
|
LINECOMMENT : [\n][ \t]* COMMENT -> channel(HIDDEN);
|
||||||
COMMENT : ';' ~[\r\n]* -> channel(HIDDEN) ;
|
COMMENT : ';' ~[\n]* -> channel(HIDDEN) ;
|
||||||
WS : [ \t] -> skip ;
|
WS : [ \t] -> skip ;
|
||||||
EOL : [\r\n]+ ;
|
EOL : [\n]+ ;
|
||||||
// WS2 : '\\' EOL -> skip;
|
// WS2 : '\\' EOL -> skip;
|
||||||
VOID: 'void';
|
VOID: 'void';
|
||||||
NAME : [a-zA-Z][a-zA-Z0-9_]* ;
|
NAME : [a-zA-Z][a-zA-Z0-9_]* ;
|
||||||
|
Loading…
Reference in New Issue
Block a user