mirror of
https://github.com/irmen/prog8.git
synced 2024-11-22 15:33:02 +00:00
* #40 grammar: handle different EOLs (Win, Unix, Mac) purely in grammar
This commit is contained in:
parent
b8117394c0
commit
3aa3659bc7
@ -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? {
|
||||
|
@ -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_]* ;
|
||||
|
Loading…
Reference in New Issue
Block a user