21 int i, in_string_index, prev_in_string_index;
28 if (inString == NULL) {
37 if (new_token_type != cur_token_type) {
38 cur_token_type = new_token_type;
47 if (*num_tokens > 0) {
57 prev_in_string_index = 0;
65 if (new_token_type != cur_token_type) {
67 tokens[i - 1].
data[in_string_index - prev_in_string_index] =
72 tokens[i].
type = new_token_type;
74 prev_in_string_index = in_string_index;
78 cur_token_type = new_token_type;
84 assert(i == *num_tokens);
87 tokens[*num_tokens].
data = NULL;
95 for (i = 0; i < num_tokens; i++) {
108 }
else if (cur ==
']') {
110 }
else if (cur ==
'{') {
112 }
else if (cur ==
'}') {
114 }
else if (cur ==
':') {
116 }
else if (cur ==
'.') {
118 }
else if (cur >=
'0' && cur <=
'9' && cur_token_type !=
TOKEN_STRING) {
127 if (token.type != token_type) {
134 INP char *instring) {
136 char *cur, *cur2, *copy, *
final;
140 while (*
final !=
'\0') {
146 while (cur !=
final) {
162 assert(i < max_i && j < max_j);
163 matrix[i][j] = atof(cur);
169 assert((i == max_i && j == 0) || (i == max_i - 1 && j == max_j));
boolean checkTokenType(INP t_token token, OUTP enum e_token_type token_type)
void my_atof_2D(INOUTP float **matrix, INP int max_i, INP int max_j, INP char *instring)
enum e_token_type GetTokenTypeFromChar(INP enum e_token_type cur_token_type, INP char cur)
void * my_calloc(size_t nelem, size_t size)
t_token * GetTokensFromString(INP const char *inString, OUTP int *num_tokens)
boolean IsWhitespace(char c)
void freeTokens(INP t_token *tokens, INP int num_tokens)
char * my_strdup(const char *str)