mirror of
https://github.com/bigsketti/cshell.git
synced 2025-06-06 21:04:46 +00:00
added identifier tokenizer function
This commit is contained in:
parent
43e3f048b8
commit
292822cc2e
23
handleJSON.c
23
handleJSON.c
@ -64,8 +64,29 @@ Token number(int *pos, char **currentChar, char *input) {
|
||||
|
||||
}
|
||||
|
||||
void tokenizeJSON() {
|
||||
Token identifier(int *pos, char **currentChar, char *input) {
|
||||
char value[100] = "";
|
||||
int i = 0;
|
||||
|
||||
while (**currentChar != '\0' && isalnum(**currentChar)) {
|
||||
if (i < sizeof(value) - 1) {
|
||||
value[i++] = **currentChar;
|
||||
}
|
||||
advancePosition(pos,currentChar, input);
|
||||
}
|
||||
value[i] = '\0';
|
||||
|
||||
Token token;
|
||||
token.type = IDENTIFIER;
|
||||
strcpy(token.value, value, sizeof(value) - 1);
|
||||
token.value[sizeof(token.value) - 1] = '\0';
|
||||
|
||||
return token;
|
||||
}
|
||||
|
||||
void tokenizeJSON(char *input) {
|
||||
// TODO: finish this after token type functions
|
||||
|
||||
}
|
||||
|
||||
// TODO: make functions to handle types of tokens
|
Loading…
x
Reference in New Issue
Block a user