Robert Hodge
15-07-2013, 16:26
C programmers are familiar with its #line directive, which assigns a line number and optional (purported) file name to subsequent lines of code, so that error messages are based on the assumptions defined on the #line directive.
I believe a similar facility would be useful for thinBasic.
In particular, when thinBasic is launched as a script engine (such as SPFLite does), the main code may wish to insert additional code as a prologue or epilogue to the main script. That could be done either by creating a temp file and appending such inserted code before or after the main script code, or by doing so in a buffer when the script is executed from memory.
However, at present, when such code insertion techniques are used, they would 'throw off' the line numbers of any diagnostic messages, at least when 'prologue' code is inserted. If there were a #LINE directive, a #LINE could also be inserted to reset the line number back to 1, so that any syntax errors in subsequent code would correctly reflect the line numbers where they appeared.
I believe a similar facility would be useful for thinBasic.
In particular, when thinBasic is launched as a script engine (such as SPFLite does), the main code may wish to insert additional code as a prologue or epilogue to the main script. That could be done either by creating a temp file and appending such inserted code before or after the main script code, or by doing so in a buffer when the script is executed from memory.
However, at present, when such code insertion techniques are used, they would 'throw off' the line numbers of any diagnostic messages, at least when 'prologue' code is inserted. If there were a #LINE directive, a #LINE could also be inserted to reset the line number back to 1, so that any syntax errors in subsequent code would correctly reflect the line numbers where they appeared.