mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-17 15:54:07 +10:00
Renemed all variables to fit into a namespace
Basically, all Toy varaibles, functions, etc. are prepended with "Toy_", and macros are prepended with "TOY_". This is to reduce namespace pollution, which was an issue pointed out to be - blame @GyroVorbis. I've also bumped the minor version number - theoretically I should bump the major number, but I'm not quite ready for 1.0 yet.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#include "lexer.h"
|
||||
#include "toy_lexer.h"
|
||||
|
||||
#include "console_colors.h"
|
||||
#include "toy_console_colors.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@@ -11,39 +11,39 @@ int main() {
|
||||
char* source = "print null;";
|
||||
|
||||
//test init & quit
|
||||
Lexer lexer;
|
||||
initLexer(&lexer, source);
|
||||
Toy_Lexer lexer;
|
||||
Toy_initLexer(&lexer, source);
|
||||
|
||||
//get each token
|
||||
Token print = scanLexer(&lexer);
|
||||
Token null = scanLexer(&lexer);
|
||||
Token semi = scanLexer(&lexer);
|
||||
Token eof = scanLexer(&lexer);
|
||||
Toy_Token print = Toy_scanLexer(&lexer);
|
||||
Toy_Token null = Toy_scanLexer(&lexer);
|
||||
Toy_Token semi = Toy_scanLexer(&lexer);
|
||||
Toy_Token eof = Toy_scanLexer(&lexer);
|
||||
|
||||
//test each token is correct
|
||||
if (strncmp(print.lexeme, "print", print.length)) {
|
||||
fprintf(stderr, ERROR "ERROR: print lexeme is wrong: %s" RESET, print.lexeme);
|
||||
fprintf(stderr, TOY_CC_ERROR "ERROR: print lexeme is wrong: %s" TOY_CC_RESET, print.lexeme);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
if (strncmp(null.lexeme, "null", null.length)) {
|
||||
fprintf(stderr, ERROR "ERROR: null lexeme is wrong: %s" RESET, null.lexeme);
|
||||
fprintf(stderr, TOY_CC_ERROR "ERROR: null lexeme is wrong: %s" TOY_CC_RESET, null.lexeme);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (strncmp(semi.lexeme, ";", semi.length)) {
|
||||
fprintf(stderr, ERROR "ERROR: semicolon lexeme is wrong: %s" RESET, semi.lexeme);
|
||||
fprintf(stderr, TOY_CC_ERROR "ERROR: semicolon lexeme is wrong: %s" TOY_CC_RESET, semi.lexeme);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (eof.type != TOKEN_EOF) {
|
||||
fprintf(stderr, ERROR "ERROR: Failed to find EOF token" RESET);
|
||||
if (eof.type != TOY_TOKEN_EOF) {
|
||||
fprintf(stderr, TOY_CC_ERROR "ERROR: Failed to find EOF token" TOY_CC_RESET);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
printf(NOTICE "All good\n" RESET);
|
||||
printf(TOY_CC_NOTICE "All good\n" TOY_CC_RESET);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user