diff --git a/bfpcompiler/include/analyzer.h b/bfpcompiler/include/analyzer.h index 38a80cd..a51608f 100644 --- a/bfpcompiler/include/analyzer.h +++ b/bfpcompiler/include/analyzer.h @@ -3,6 +3,7 @@ #include #include +#include /** * @name analyze @@ -10,7 +11,8 @@ * @brief Analyze the tokens syntax. Return -1 on error and 1 on warning, 0 else. * * @param char* tokens: analyze_tokens + * @param char* device: target device */ -int analyze (char* tokens); +int analyze (char* tokens, char* device); #endif//ANALYZER_H diff --git a/bfpcompiler/src/analyzer.c b/bfpcompiler/src/analyzer.c index fbe0720..5c18373 100644 --- a/bfpcompiler/src/analyzer.c +++ b/bfpcompiler/src/analyzer.c @@ -6,8 +6,9 @@ * @brief Check for errors and warnings. * * @param char* token + * @param char* device */ -int analyze (char* token) { +int analyze (char* token, char* device) { int rv = 0; int position = 0; @@ -28,8 +29,8 @@ int analyze (char* token) { break; } - /* check for nested loops */ - if (rv > 1) { + /* check for nested loops in case of using the logisim model */ + if (rv > 1 && !strcmp(device, "logisim")) { (void)printf("Warning on token %d\n", position); (void)printf("WARNING: Nested loops are not supported on all versions of the target device!\n"); } diff --git a/bfpcompiler/src/tokenizer.c b/bfpcompiler/src/tokenizer.c index ce1693c..c78ffb0 100644 --- a/bfpcompiler/src/tokenizer.c +++ b/bfpcompiler/src/tokenizer.c @@ -38,6 +38,9 @@ int extractTokens (char* buffer, char* tokens) { } + /* Terminate the array using a null character */ + tokens[tokens_found] = 0; /* same as \0 */ + rv = tokens_found; return rv;