I'm working on a DSL compiler and want to provide more friendly information for user. So I remember that those mature compilers like GCC or GHC all can point out what semantics error happened in which lines, and they even can strip them from generated codes.
The first idea is to add linenumbers in my AST while parsing. But I'm not sure if this is a standard solution, or there're other better ways to do that ? I doubt it because this solution ask every nodes in the AST to bring extra data, and they may become burden.