c = fgetwc(source); // lecture du premier caractere
do {
scanner();
- wprint_token_target();
+ wprint_token(target);
token[tokenFound].type = tokenTypestr[tokenType];
tokenFound++;
} while (tokenType != FIN); // tant que la fin du fichier n'est pas atteinte
-#include <stdarg.h>
#include <stdio.h>
#include <wchar.h>
+#include "print_helper.h"
#include "global_vars.h"
void pr_warning(const char* format, ...) {
fflush(stderr);
}
-void wprint_token_stdout() {
+void wprint_token(FILE* out_file) {
if (tokenType == MOT || tokenType == MOTCLE) {
- fwprintf(stdout, L"%20s: %ls\n", tokenTypestr[tokenType], token[tokenFound].value);
+ fwprintf(out_file, L"%20s: %ls\n", tokenTypestr[tokenType], token[tokenFound].value);
} else {
- fwprintf(stdout, L"%20s\n", tokenTypestr[tokenType]);
- }
- fflush(stdout);
-}
-
-void wprint_token_target() {
- if (tokenType == MOT || tokenType == MOTCLE) {
- fwprintf(target, L"%20s: %ls\n", tokenTypestr[tokenType], token[tokenFound].value);
- } else {
- fwprintf(target, L"%20s\n", tokenTypestr[tokenType]);
+ fwprintf(out_file, L"%20s\n", tokenTypestr[tokenType]);
}
+ fflush(out_file);
}
#ifndef PRINT_HELPER_H_
#define PRINT_HELPER_H_
+#include <stdio.h>
+
void pr_warning(const char *format, ...);
void pr_error(const char *format, ...);
void wpr_warning(const wchar_t *format, ...);
void wpr_error(const wchar_t *format, ...);
-void wprint_token_stdout();
-void wprint_token_target();
+void wprint_token(FILE* out_file);
#endif /* PRINT_HELPER_H_ */
fputws(L" ", target);
}
#if PRINT_TOKEN
- wprint_token_stdout();
+ wprint_token(stdout);
#endif
token[tokenFound].type = tokenTypestr[tokenType];
tokenFound++;
if (tokenType == NPARA) {
scanner();
#if PRINT_TOKEN
- wprint_token_stdout();
+ wprint_token(stdout);
#endif
if (target != NULL) {
fputws(L"<p>\n", target);
if (tokenType == MOT) {
scanner();
#if PRINT_TOKEN
- wprint_token_stdout();
+ wprint_token(stdout);
#endif
if (target != NULL) {
fputws((const wchar_t*)token[tokenFound].value, target);
if (tokenType == MOTCLE) {
scanner();
#if PRINT_TOKEN
- wprint_token_stdout();
+ wprint_token(stdout);
#endif /* PRINT_TOKEN */
token[tokenFound].type = tokenTypestr[tokenType];
tokenFound++;
if (tokenType == MOTCLE) {
scanner();
#if PRINT_TOKEN
- wprint_token_stdout();
+ wprint_token(stdout);
#endif /* PRINT_TOKEN */
token[tokenFound].type = tokenTypestr[tokenType];
tokenFound++;
if (tokenType == SECTION) {
scanner();
#if PRINT_TOKEN
- wprint_token_stdout();
+ wprint_token(stdout);
#endif /* PRINT_TOKEN */
if (target != NULL) {
fputws(L"<h1>\n", target);
if (tokenType == SSECTION) {
scanner();
#if PRINT_TOKEN
- wprint_token_stdout();
+ wprint_token(stdout);
#endif /* PRINT_TOKEN */
if (target != NULL) {
fputws(L"<h2>\n", target);
scanner();
/* print the lexical analysis result */
#if PRINT_TOKEN
- wprint_token_stdout();
+ wprint_token(stdout);
#endif /* PRINT_TOKEN */
token[tokenFound].type = tokenTypestr[tokenType];
tokenFound++;