Code cleanups.
[TP_AL_C.git] / lexer / print_helper.c
CommitLineData
9ed84d89 1#include <stdio.h>
15ad4b5a 2#include <stdarg.h>
9ed84d89 3
f196dae5 4#include "print_helper.h"
e70feb8c
JB
5#include "global_vars.h"
6
7void pr_warning(const char* format, ...) {
9ed84d89
JB
8 va_list args;
9
10 va_start(args, format);
11 fprintf(stdout, format, args);
12 va_end(args);
6c47be32 13 fflush(stdout);
9ed84d89
JB
14}
15
16void pr_error(const char *format, ...) {
17 va_list args;
18
19 va_start(args, format);
20 fprintf(stderr, format, args);
21 va_end(args);
6c47be32 22 fflush(stderr);
9ed84d89
JB
23}
24
e70feb8c
JB
25#if DEBUG
26void pr_debug(const char *format, ...) {
27 va_list args;
28
29 va_start(args, format);
30 fprintf(stderr, format, args);
31 va_end(args);
6c47be32 32 fflush(stderr);
e70feb8c
JB
33}
34#else
35void pr_debug(const char *format, ...);
36#endif /* DEBUG */
37
9ed84d89
JB
38void wpr_warning(const wchar_t *format, ...) {
39 va_list args;
40
41 va_start(args, format);
42 fwprintf(stdout, format, args);
43 va_end(args);
6c47be32 44 fflush(stdout);
9ed84d89
JB
45}
46
47void wpr_error(const wchar_t *format, ...) {
48 va_list args;
49
50 va_start(args, format);
51 fwprintf(stderr, format, args);
52 va_end(args);
6c47be32 53 fflush(stderr);
9ed84d89 54}
e70feb8c 55
f196dae5 56void wprint_token(FILE* out_file) {
48e4b4ad 57 if (tokenType == MOT || tokenType == MOTCLE) {
f196dae5 58 fwprintf(out_file, L"%20s: %ls\n", tokenTypestr[tokenType], token[tokenFound].value);
48e4b4ad 59 } else {
f196dae5 60 fwprintf(out_file, L"%20s\n", tokenTypestr[tokenType]);
e70feb8c 61 }
f196dae5 62 fflush(out_file);
e70feb8c 63}
15ad4b5a
JB
64
65void wprint_ctoken(FILE* out_file) {
66 if (tokenType == MOT || tokenType == MOTCLE) {
67 fwprintf(out_file, L"%20s: %ls\n", tokenTypestr[tokenType], tokenValue);
68 } else {
69 fwprintf(out_file, L"%20s\n", tokenTypestr[tokenType]);
70 }
71 fflush(out_file);
72}