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

Track source position of else if

This commit is contained in:
Karol Stasiak 2019-01-04 11:54:46 +01:00
parent b1374bb914
commit bf0da19ab9

View File

@ -382,7 +382,10 @@ abstract class MfParser[T](fileId: String, input: String, currentDirectory: Stri
def ifStatement: P[Seq[ExecutableStatement]] = for { def ifStatement: P[Seq[ExecutableStatement]] = for {
condition <- "if" ~ !letterOrDigit ~/ HWS ~/ mfExpression(nonStatementLevel, false) condition <- "if" ~ !letterOrDigit ~/ HWS ~/ mfExpression(nonStatementLevel, false)
thenBranch <- AWS ~/ executableStatements thenBranch <- AWS ~/ executableStatements
elseBranch <- (AWS ~ "else" ~/ AWS ~/ (ifStatement | executableStatements)).? elseBranch <- (AWS ~ "else" ~/ AWS ~/ ((for{
p <- position()
s <- ifStatement
} yield s.map(_.pos(p))) | executableStatements)).?
} yield Seq(IfStatement(condition, thenBranch.toList, elseBranch.getOrElse(Nil).toList)) } yield Seq(IfStatement(condition, thenBranch.toList, elseBranch.getOrElse(Nil).toList))
def whileStatement: P[Seq[ExecutableStatement]] = for { def whileStatement: P[Seq[ExecutableStatement]] = for {