Extend MTL to handle \include and \input directives.
I thought initially that this would require a multi-pass system so that error messages could be reasonable. Is this the best way?
Some thoughts:
It might be possible to keep track of line numbers separately, perhaps by controlling what line number we are at in the lexer.
Files could be read and input by the lexer? For example, when we see an \input{filename}, we could read in the filename and continue lexing it. This would require injecting the file's contents into the lexing buffer. And probably inserting an end of file marker so that we can adjust line numbers for error messaging.
Maintain a stack of lexbuf's. When you encounter a new \input or \include, create a lexbuf and continue lexing through that, when that one finishes switch to the old one.
Extend MTL to handle \include and \input directives.
I thought initially that this would require a multi-pass system so that error messages could be reasonable. Is this the best way?
Some thoughts:
It might be possible to keep track of line numbers separately, perhaps by controlling what line number we are at in the lexer.
Files could be read and input by the lexer? For example, when we see an \input{filename}, we could read in the filename and continue lexing it. This would require injecting the file's contents into the lexing buffer. And probably inserting an end of file marker so that we can adjust line numbers for error messaging.