Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2012-02

possibility to include compiler info (line number) as integer rather than string

5 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Seth Grover

Quoting http://www.freepascal.org/docs-html/prog/progsu38.html

--------------------
the {$INCLUDE} directive inserts a string constant in the source code.

...
LINE
Linenumer on which the directive is found.
--------------------

How hard would it be for me to modify the FPC preprocessor to add an option (INTLINE or something) to insert a numeric constant in the source code rather than a string constant?

If that would be doable, could anyone give me a pointer on where in the source code I'd look to begin? I haven't delved much into that realm of the compiler's code as of yet.

Thanks,

-SG

This email is fiction. Any resemblance to actual events or persons living or dead is purely coincidental. Seth Grover

Reply by email

Seth Grover
to Seth Grover

Actually I already found it, and it will be trivial to do.

Would this be useful to anyone else? Should I submit a patch? Basically I'm adding a "LINENUM" macro (vs. the existing "LINE" macro) which inserts the line number as an numeric rather than a string constant.

-SG

This email is fiction. Any resemblance to actual events or persons living or dead is purely coincidental. Seth Grover On Fri, Feb 24, 2012 at 2:49 PM, Seth Grover wrote: > Quoting http://www.freepascal.org/docs-html/prog/progsu38.html > > -------------------- > the {$INCLUDE} directive inserts a string constant in the source code. > > ... > LINE >    Linenumer on which the directive is found. > -------------------- > > How hard would it be for me to modify the FPC preprocessor to add an > option (INTLINE or something) to insert a numeric constant in the > source code rather than a string constant? > > If that would be doable, could anyone give me a pointer on where in > the source code I'd look to begin? I haven't delved much into that > realm of the compiler's code as of yet. > > Thanks, > > -SG > > > > -- > This email is fiction. Any resemblance to actual events > or persons living or dead is purely coincidental. > > Seth Grover

Reply by email

Sven Barth
to Seth Grover: Quoting http://www.freepascal.org/docs-html/prog/progsu38.html -------------------- the…
Seth Grover wrote 17 lines
Quoting http://www.freepascal.org/docs-html/prog/progsu38.html -------------------- the {$INCLUDE} directive inserts a string constant in the source code. ... LINE Linenumer on which the directive is found. -------------------- How hard would it be for me to modify the FPC preprocessor to add an option (INTLINE or something) to insert a numeric constant in the source code rather than a string constant? If that would be doable, could anyone give me a pointer on where in the source code I'd look to begin? I haven't delved much into that realm of the compiler's code as of yet.
{$INCLUDE ...} is handled in compiler/scanner.pas in dir_include. You'll
find a "hs='LINE'" there, which gets the line number, and further below
a "hs:=''''+hs+''''" which converts hs to a string constant and inserts
it into the scanner.

So basically you'll need to add a new directive (normally in compiler/scandir.pas, which should be sufficient in your case), add the ingredients above without the conversion to a string constant and that should be it in theory (note: I have not tested this, just a quick glance at the code).

Note: To add your directive procedure to the scanner you need to register it in InitScannerDirectives at the bottom of unit scandir.

Regards,
Sven

Reply by email

Sven Barth
to Seth Grover: Actually I already found it, and it will be trivial to do. Would this be useful to anyone…
Seth Grover wrote 6 lines
Actually I already found it, and it will be trivial to do. Would this be useful to anyone else? Should I submit a patch? Basically I'm adding a "LINENUM" macro (vs. the existing "LINE" macro) which inserts the line number as an numeric rather than a string constant.

Ah, so you already found it. And I also got your intention a bit wrong, so please ignore the part about the scandir unit ;)

Regards,
Sven

Reply by email

Seth Grover
to Seth Grover: Actually I already found it, and it will be trivial to do. Would this be useful to anyone…

I've provided a patch.

http://mantis.freepascal.org/view.php?id=21372

Cheers,

-SG

This email is fiction. Any resemblance to actual events or persons living or dead is purely coincidental. Seth Grover On Fri, Feb 24, 2012 at 3:13 PM, Seth Grover wrote: > Actually I already found it, and it will be trivial to do. > > Would this be useful to anyone else? Should I submit a patch? > Basically I'm adding a "LINENUM" macro (vs. the existing "LINE" macro) > which inserts the line number as an numeric rather than a string > constant. > > -SG > > > -- > This email is fiction. Any resemblance to actual events > or persons living or dead is purely coincidental. > > Seth Grover > > > > On Fri, Feb 24, 2012 at 2:49 PM, Seth Grover wrote: >> Quoting http://www.freepascal.org/docs-html/prog/progsu38.html >> >> -------------------- >> the {$INCLUDE} directive inserts a string constant in the source code. >> >> ... >> LINE >>    Linenumer on which the directive is found. >> -------------------- >> >> How hard would it be for me to modify the FPC preprocessor to add an >> option (INTLINE or something) to insert a numeric constant in the >> source code rather than a string constant? >> >> If that would be doable, could anyone give me a pointer on where in >> the source code I'd look to begin? I haven't delved much into that >> realm of the compiler's code as of yet. >> >> Thanks, >> >> -SG >> >> >> >> -- >> This email is fiction. Any resemblance to actual events >> or persons living or dead is purely coincidental. >> >> Seth Grover

Reply by email