Highlighting text as an error from outside compiler

We have an external query compiler that returns a line number and char index in the query that is in error. I’d like CodeMirror.defineMode token function to return ‘error’ for the current token if it falls in that error position. How do I pass this external error position into the CodeMirror.defineMode token function? Can I get the current line and char in the token function? Thank you

Using a mode for that doesn’t really work, but with markText this shouldn’t be too hard.

Great, thank you!