1
0
mirror of https://github.com/KarolS/millfork.git synced 2024-12-23 08:29:35 +00:00

Source file name in preprocessor errors

This commit is contained in:
Karol Stasiak 2018-12-24 01:20:41 +01:00
parent acaaa5bdfe
commit aebae97cc8
2 changed files with 5 additions and 5 deletions

View File

@ -60,13 +60,13 @@ abstract class AbstractSourceLoadingQueue[T](val initialFilenames: List[String],
options.log.debug(s"Parsing $filename")
val path = Paths.get(filename)
val parentDir = path.toFile.getAbsoluteFile.getParent
val PreprocessingResult(src, featureConstants, pragmas) = Preprocessor(options, Files.readAllLines(path, StandardCharsets.UTF_8).toIndexedSeq)
val shortFileName = path.getFileName.toString
val PreprocessingResult(src, featureConstants, pragmas) = Preprocessor(options, shortFileName, Files.readAllLines(path, StandardCharsets.UTF_8).toIndexedSeq)
for (pragma <- pragmas) {
if (!supportedPragmas(pragma._1)) {
options.log.warn(s"Unsupported pragma: #pragma $pragma", Some(Position(moduleName, pragma._2, 1, 0)))
}
}
val shortFileName = path.getFileName.toString
val parser = createParser(shortFileName, src, parentDir, featureConstants, pragmas.keySet)
options.log.addSource(shortFileName, src.lines.toIndexedSeq)
parser.toAst match {

View File

@ -18,12 +18,12 @@ object Preprocessor {
private val Regex = raw"\A\s*#\s*([a-z]+)\s*(.*?)\s*\z".r
def preprocessForTest(options: CompilationOptions, code: String): PreprocessingResult = {
apply(options, code.lines.toSeq)
apply(options, "", code.lines.toSeq)
}
case class IfContext(hadEnabled: Boolean, hadElse: Boolean, enabledBefore: Boolean)
def apply(options: CompilationOptions, lines: Seq[String]): PreprocessingResult = {
def apply(options: CompilationOptions, shortFileName: String, lines: Seq[String]): PreprocessingResult = {
val platform = options.platform
val log = options.log
// if (log.traceEnabled) {
@ -55,7 +55,7 @@ object Preprocessor {
var resulting = ""
line match {
case Regex(keyword, param) =>
val pos = Some(Position("", lineNo, 0, 0))
val pos = Some(Position(shortFileName, lineNo, 0, 0))
keyword match {
case "use" => if (enabled) {
if (param == "") log.error("#use should have a parameter", pos)