1
0
mirror of https://github.com/KarolS/millfork.git synced 2024-06-25 19:29:49 +00:00

Be more helpful for C users

This commit is contained in:
Karol Stasiak 2019-07-17 20:49:36 +02:00
parent 11825c43e1
commit 8d8859b55f

View File

@ -124,7 +124,12 @@ object Preprocessor {
}
}
case "else" =>
if (param != "") log.error("#else shouldn't have a parameter", pos)
if (param != "") {
log.error("#else shouldn't have a parameter", pos)
if (param.startsWith("if ")) {
log.error("Did you mean: #elseif")
}
}
if (ifStack.isEmpty) log.error("Unmatched #else", pos)
else {
val i = ifStack.top
@ -141,6 +146,18 @@ object Preprocessor {
if (param == "") log.error("#pragma should have a parameter", pos)
pragmas += param -> lineNo
}
case "ifdef" =>
log.error("Invalid preprocessor directive: #" + keyword, pos)
log.error("Did you mean: #if defined(" + param + ")")
case "ifndef" =>
log.error("Invalid preprocessor directive: #" + keyword, pos)
log.error("Did you mean: #if not(defined(" + param + "))")
case "elif" | "elsif" =>
log.error("Invalid preprocessor directive: #" + keyword, pos)
log.error("Did you mean: #elseif")
case "undef" =>
log.error("Invalid preprocessor directive: #" + keyword, pos)
log.error("A once defined feature cannot be undefined")
case _ =>
log.error("Invalid preprocessor directive: #" + keyword, pos)