* #40 grammar: handle different EOLs (Win, Unix, Mac) purely in grammar

This commit is contained in:
meisl 2021-06-12 20:24:15 +02:00
parent b8117394c0
commit 3aa3659bc7
2 changed files with 4 additions and 6 deletions

View File

@ -44,9 +44,7 @@ class ModuleImporter(private val program: Program,
if(!Files.isReadable(filePath))
throw ParsingFailedError("No such file: $filePath")
var content = filePath.toFile().readText().replace("\r\n", "\n") // normalize line endings
return importModule(CharStreams.fromString(content), filePath, false)
return importModule(CharStreams.fromPath(filePath), filePath, false)
}
fun importLibraryModule(name: String): Module? {

View File

@ -15,10 +15,10 @@ grammar prog8;
package prog8.parser;
}
LINECOMMENT : [\n][ \t]* COMMENT -> channel(HIDDEN);
COMMENT : ';' ~[\n]* -> channel(HIDDEN) ;
LINECOMMENT : ('\r'? '\n' | '\r') [ \t]* COMMENT -> channel(HIDDEN);
COMMENT : ';' ~[\r\n]* -> channel(HIDDEN) ;
WS : [ \t] -> skip ;
EOL : [\n]+ ;
EOL : ('\r'? '\n' | '\r')+ ;
// WS2 : '\\' EOL -> skip;
VOID: 'void';
NAME : [a-zA-Z][a-zA-Z0-9_]* ;