M
M. Uli Kusterer
Hi,
I'm writing a program that generates Java code from source code written
in another language. Now, when an error occurs, I'd like to have Java
report the file name and line number in the source file the user wrote.
C has a #line directive for that. Does Java have something similar?
In case I'm not clear, an example:
UserCode.p:
1: PROCEDURE Main
2: begin
4: logFilePathsStartingAt( "/dev" );
5: end
GeneratedCode.java
1: public static class UserCode
2: {
3: public static void main( String[] argv )
4: {
5: CreateLogWindow();
6:
7: PUtilityCode.LogFilePathsStartingAt( "/dev" );
8: }
9: }
Now, when an error occurs in line 7 of GeneratedCode.java, I would like
Java to tell the user "there was an error on line 4 in UserCode.p".
C has a "#line" preprocessor directive which I could write on line 6 as:
6: #line 4
and from then on any errors would be reported to be in line 4.
Thanks for any clues,
-- Uli
http://www.zathras.de
I'm writing a program that generates Java code from source code written
in another language. Now, when an error occurs, I'd like to have Java
report the file name and line number in the source file the user wrote.
C has a #line directive for that. Does Java have something similar?
In case I'm not clear, an example:
UserCode.p:
1: PROCEDURE Main
2: begin
4: logFilePathsStartingAt( "/dev" );
5: end
GeneratedCode.java
1: public static class UserCode
2: {
3: public static void main( String[] argv )
4: {
5: CreateLogWindow();
6:
7: PUtilityCode.LogFilePathsStartingAt( "/dev" );
8: }
9: }
Now, when an error occurs in line 7 of GeneratedCode.java, I would like
Java to tell the user "there was an error on line 4 in UserCode.p".
C has a "#line" preprocessor directive which I could write on line 6 as:
6: #line 4
and from then on any errors would be reported to be in line 4.
Thanks for any clues,
-- Uli
http://www.zathras.de