Skip to main content
Version: Next

Message Handling

CL error handling centers on MONMSG (monitor message) and outbound messaging via SNDMSG / SNDPGMMSG. Extracting monitors and their EXEC bodies is a common first step for reliability reviews and migration of exception paths.

Add Dependencies​

repositories {
mavenLocal()
mavenCentral()
flatDir {
dirs("deps")
}
}

dependencies {
implementation(files("deps/clparser-with-dependencies-1.0.1-all.jar"))
}

List MONMSG monitors and EXEC bodies​

MonitorMessageCommand carries message ids in msgid. Nested EXEC(...) commands appear as CLExecKeyword entries among the command parameters (including EXEC(DO)…ENDDO groups after control-flow nesting).

import com.strumenta.cl.model.CLExecKeyword
import com.strumenta.cl.model.CLExpression
import com.strumenta.cl.model.CLLiteral
import com.strumenta.cl.model.CLReferenceExpr
import com.strumenta.cl.model.MonitorMessageCommand
import com.strumenta.cl.model.SendMessageCommand
import com.strumenta.cl.model.SendProgramMessageCommand
import com.strumenta.cl.parser.CLKolasuParser
import com.strumenta.kolasu.commercial.LicenseManager
import com.strumenta.kolasu.traversing.walkDescendants
import java.io.File

fun formatExpr(expr: CLExpression?): String =
when (expr) {
is CLReferenceExpr -> expr.name.name
is CLLiteral -> expr.text
null -> "?"
else -> expr.toString()
}

fun printMessageHandling(clFile: File, license: File) {
LicenseManager.registerLicense(license)
val root = CLKolasuParser().parse(clFile).root ?: return

println("MONMSG:")
root.walkDescendants(MonitorMessageCommand::class).forEach { mon ->
val ids = mon.msgid.joinToString { formatExpr(it) }
println(" msgids=[$ids]")
mon.parameters.filterIsInstance<CLExecKeyword>().forEach { exec ->
println(" EXEC → ${exec.command.simpleNodeType}")
}
}

val sndMsg = root.walkDescendants(SendMessageCommand::class).count()
val sndPgmMsg = root.walkDescendants(SendProgramMessageCommand::class).count()
println("SNDMSG: $sndMsg")
println("SNDPGMMSG: $sndPgmMsg")
}

Combine this with control-flow aware walks when EXEC(DO) wraps multiple recovery commands, and with program inventory when estimating exception-handling density across a library.