Hacker News new | ask | show | jobs
by andybest 2986 days ago
Interesting, I wasn't aware of the #line directive, thanks!

Yes, you would need to keep track of the source locations for each node in the AST. There is a nice example in the LLVM Kaleidoscope tutorial here: https://llvm.org/docs/tutorial/LangImpl09.html

1 comments

Bison and lex use #line to make generated C/C++ code (lexer, parser) debuggable, or at least their GNU implementation does, I don't know about other implementations.