Convert tables to STRINGARRAY

This commit is contained in:
Augusto Gunsch
2020-12-22 16:00:49 -03:00
parent abef39c1c6
commit 2e48e42368
5 changed files with 14 additions and 14 deletions

View File

@@ -2,17 +2,18 @@
#define TOKENIZER_TABLES_H
#include "util.h"
const char* keywords[] = {
const char* keywordsraw[] = {
"class", "constructor", "function", "method", "field", "static",
"var", "int", "char", "boolean", "void", "true", "false", "null",
"this", "let", "do", "if", "else", "while", "return"
};
const int keywordssize = strcount(keyword);
mkstrlist(keywords, keywordsraw);
const char* symbols[] = {
const char* symbolsraw[] = {
"{", "}", "(", ")", "[", "]", ".", ",", ";", "+", "-", "*", "/",
"&", "|", "<", ">", "=", "~"
};
const int symbolssize = strcount(symbols);
mkstrlist(symbols, symbolsraw);
#endif

View File

@@ -91,19 +91,13 @@ CHARTYPE getchartype(unsigned char c) {
}
bool iskeyword(STRING* tk) {
for(int i = 0; i < keywordssize; i++)
if(!strcmp(tk->str, keywords[i]))
return true;
return false;
return existsinarray(&keywords, tk->str);
}
bool issymbol(STRING* tk) {
if(tk->count != 2)
return false;
for(int i = 0; i < symbolssize; i++)
if(!strcmp(tk->str, symbols[i]))
return true;
return false;
return existsinarray(&symbols, tk->str);
}
bool isint(char* str) {