diff options
author | Linus Torvalds <torvalds@home.transmeta.com> | 2003-03-13 15:03:49 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-07 20:59:14 -0700 |
commit | 90247bd7671b301cd30f43b40cc47e71392a1c04 (patch) | |
tree | 2ba802b6f4d7a2d033a1e4bb09f77db359144aa5 /lib.c | |
parent | Ignore object files and the test app (diff) | |
download | sparse-90247bd7671b301cd30f43b40cc47e71392a1c04.tar.gz sparse-90247bd7671b301cd30f43b40cc47e71392a1c04.tar.bz2 sparse-90247bd7671b301cd30f43b40cc47e71392a1c04.zip |
Add simple recursive-descent C expression parsing (but we only do the
simple binops so far, type parsing is still way off).
Clean up and update tokenization.
Diffstat (limited to 'lib.c')
-rw-r--r-- | lib.c | 39 |
1 files changed, 39 insertions, 0 deletions
@@ -0,0 +1,39 @@ +/* + * Helper routines + */ +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h> +#include "token.h" + +void warn(struct token *token, const char * fmt, ...) +{ + static char buffer[512]; + struct stream *stream; + + va_list args; + va_start(args, fmt); + vsprintf(buffer, fmt, args); + va_end(args); + + stream = input_streams + token->stream; + fprintf(stderr, "warning: %s:%d: %s\n", + stream->name, token->line, + buffer); +} + + +void die(const char *fmt, ...) +{ + va_list args; + static char buffer[512]; + + va_start(args, fmt); + vsnprintf(buffer, sizeof(buffer), fmt, args); + va_end(args); + + fprintf(stderr, "%s\n", buffer); + exit(1); +} + + |