Simple C parsing (Shawn Hargreaves)
Thu, 27 Oct 1994 04:48:39 GMT

          From comp.compilers

Related articles
Simple C parsing (1994-10-27)
Re: Simple C parsing (1994-10-30)
| List of all articles for this month |

Newsgroups: comp.compilers
From: (Shawn Hargreaves)
Keywords: C, parse, question
Organization: UTexas Mail-to-News Gateway
Date: Thu, 27 Oct 1994 04:48:39 GMT

I am using an old K&R C compiler on an Atari ST, which does not support
source level debugging. Since I don't have the hardware to run a better
compiler, I am thinking about implementing a debugger as an add-on to the
existing compiler. I think the way to do this would be to have a code
preprocessor that would insert macros into the source code in between
every line, and these macros would call the debugger directly rather than
using interrupts and a symbol table. For example, the code:

main() {
printf("This is a test\n");

would be converted to:

main() { DEBUG_FUNCTION_START("main");
printf("This is a test\n"); DEBUG_LINE(2);
exit(0); DEBUG_LINE(3);

The debug calls would access a library of functions which would display
the position in the source code and support usual features like
single-stepping, breakpoints, examine variables and so on. This system
would work with any compiler, and should also be easily portable to lots
of different OS's.

My question is, what is the fastest and most reliable way of deciding
where to insert the macro calls? I don't want to have to write a complete
parser if I can avoid it, since all I need is to split the source file up
into variable declarations and lines of code, so that I can insert the
appropriate macro between each one. Does anyone know a fast, easy way of
doing this? Any suggestions would be much appreciated.

Shawn Hargreaves

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.