- Preparing search index...
- The search index is not available
Kombo - v3.0.0
Type alias DeadEnd<CTX, PROBLEM>
Dead
End
<CTX, PROBLEM>: { col
: number; contextStack
: immutable.Stack<Located<CTX>>; problem
: PROBLEM; row
: number; }
Type declaration
-
col: number
-
contextStack: immutable.Stack<Located<CTX>>
-
problem: PROBLEM
-
row: number
When we reach a deadend we return all the information you need to create great error message.
Example
Say you are parsing a function named
viewHealthData
that contains a list. You might get aDeadEnd
like this:We have a ton of information here! So in the error message, we can say that “I ran into an issue when parsing a
list
in the definition ofviewHealthData
. It looks like there is an extra comma.” Or maybe something even better!Furthermore, many parsers just put a mark where the problem manifested. By tracking the
row
andcol
of the context, we can show a much larger region as a way of indicating “I thought I was parsing this thing that starts over here.” Otherwise, you can get very confusing error messages on a missing]
or}
or)
because “I need more indentation” on something unrelated.Note: Rows and columns are counted like a text editor. The beginning is
row=1
andcol=1
. Thecol
increments as characters are chomped. When a\n
is chomped,row
is incremented andcol
starts over again at1
.See