When you say you have "done this", does what exactly does this mean? that the current stlc compiler does this, or that this is common practice, or that you've written a compiler at one time that does this?
I've looked at the slides and the zip file and see no mention of positions anywhere. I do see monads for line numbers mentioned in
http://www.haskell.org/happy/doc/html/sec-monads.html#sec-line-numbers
However that seems to be a single line number. Best of course would be [start column, start line] and [end column, end line] as suggested in the output when I gave
a / b
^^^^
In stlc.y what I see related to errors is this:
lexer (c:cs)
| isSpace c = lexer cs
| isDigit c = lexNum (c:cs)
| isSymChar c = lexSym (c:cs)
| otherwise = error $ "Unexpected character: '" ++ show c ++ "'."
parseError _ = error "Parse error"
parseError :: [Token] -> a
parseError _ = error "Parse error"
Is there someplace else I should be looking?
Given my vague understanding -- and it is vague -- I could be very wrong.
It sounds like what you are saying is that you have a parser system and a methodology (of using monads attached to tokens) whereby if one wants to capture position information that's possible if you want to code that way.
If that's the case, that is a little different than some sort of packaged setup where this position information code is already bundled or templated and all I have to do is somehow indicate I want it or not, even if by including a particular file that defines the monads for positions.