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