mirror of
https://github.com/irmen/prog8.git
synced 2024-11-26 11:49:22 +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))
|
if(!Files.isReadable(filePath))
|
||||||
throw ParsingFailedError("No such file: $filePath")
|
throw ParsingFailedError("No such file: $filePath")
|
||||||
|
|
||||||
var content = filePath.toFile().readText().replace("\r\n", "\n") // normalize line endings
|
return importModule(CharStreams.fromPath(filePath), filePath, false)
|
||||||
|
|
||||||
return importModule(CharStreams.fromString(content), filePath, false)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun importLibraryModule(name: String): Module? {
|
fun importLibraryModule(name: String): Module? {
|
||||||
|
@ -15,10 +15,10 @@ grammar prog8;
|
|||||||
package prog8.parser;
|
package prog8.parser;
|
||||||
}
|
}
|
||||||
|
|
||||||
LINECOMMENT : [\n][ \t]* COMMENT -> channel(HIDDEN);
|
LINECOMMENT : ('\r'? '\n' | '\r') [ \t]* COMMENT -> channel(HIDDEN);
|
||||||
COMMENT : ';' ~[\n]* -> channel(HIDDEN) ;
|
COMMENT : ';' ~[\r\n]* -> channel(HIDDEN) ;
|
||||||
WS : [ \t] -> skip ;
|
WS : [ \t] -> skip ;
|
||||||
EOL : [\n]+ ;
|
EOL : ('\r'? '\n' | '\r')+ ;
|
||||||
// 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