-
Notifications
You must be signed in to change notification settings - Fork 0
Expression Traces
// // Example of what an expression trace with line // numbering might look like. // // (+ <- example:27:18 // (+ <- example:23:11 // 2 <- example:20:9 // 3 <- example:21:9 // ) // 3 <- example:27:20 // ) // // Here's another potential example: // // (2 + 3) <- example.efrs:23 // + 3 <- example.efrs:27 // // Essentially here we're following the rule that we will // omit parts of the expression trace if they are a simple application of // a function to constants in the source code, which avoids something overly // explicit trace such as: // // (2 <- ... // + <- ... // 3) <- ... // + <- ... // 3 <- ... //
// How would we build an "expression trace?"
(2 + 3) + 3
is really
+(+(2, 3), 3)
which we could convert to reverse polish notation as:
2 3 + 3 +
which we could then turn into an "expression trace" like:
Encountered divide-by-zero error in some_func (example.efrs:39:11).
The denominator was 0 because of the runtime values:
at example.efrs:5 -> 2 (constant)
at example.efrs:7 -> 3 (constant)
at example.efrs:11 -> 5 (applied function "+")
at example.efrs:13 -> 3 (constant)
at example.efrs:17 -> 8 (applied function "+")
at example.efrs:19 -> 8 (constant)
at example.efrs:19 -> 0 (applied function "-")