Type alias DeadEnd<CTX, PROBLEM>

DeadEnd<CTX, PROBLEM>: {
    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 a DeadEnd like this:

{ row : 18
, col : 22
, problem : "UnexpectedComma"
, contextStack :
[ { row : 14
, col : 1
, context : "ViewHealthData"
}
, { row : 15
, col : 4
, context : "List"
}
]
}

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 of viewHealthData. 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 and col 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 and col=1. The col increments as characters are chomped. When a \n is chomped, row is incremented and col starts over again at 1.

See

Type Parameters

  • CTX

  • PROBLEM

Type declaration

  • col: number
  • contextStack: immutable.Stack<Located<CTX>>
  • problem: PROBLEM
  • row: number