Add dstr_resize and rename the dstring functions
This commit is contained in:
@@ -408,7 +408,7 @@ lexer_state_t handle_array(lexer_t *lexer, char input) {
|
||||
}
|
||||
|
||||
lexer_state_t handle_key(lexer_t *lexer, char input) {
|
||||
append_to_dstr(&(lexer->current_string), input);
|
||||
dstr_append(&(lexer->current_string), input);
|
||||
|
||||
return LEXER_STATE_STRING;
|
||||
}
|
||||
@@ -417,7 +417,7 @@ lexer_state_t handle_value(lexer_t *lexer, char input) {
|
||||
if (isspace(input)) {
|
||||
return LEXER_STATE_VALUE;
|
||||
} else if (isdigit(input) && input != '0') {
|
||||
append_to_dstr(&(lexer->current_string), input);
|
||||
dstr_append(&(lexer->current_string), input);
|
||||
|
||||
return LEXER_STATE_NUMBER;
|
||||
}
|
||||
@@ -428,7 +428,7 @@ lexer_state_t handle_value(lexer_t *lexer, char input) {
|
||||
|
||||
return LEXER_STATE_STRING;
|
||||
case '0':
|
||||
append_to_dstr(&(lexer->current_string), input);
|
||||
dstr_append(&(lexer->current_string), input);
|
||||
|
||||
return LEXER_STATE_DECIMAL;
|
||||
case '{':
|
||||
@@ -449,14 +449,14 @@ lexer_state_t handle_value(lexer_t *lexer, char input) {
|
||||
lexer_state_t handle_string(lexer_t *lexer, char input) {
|
||||
switch (input) {
|
||||
case '\\':
|
||||
append_to_dstr(&(lexer->current_string), input);
|
||||
dstr_append(&(lexer->current_string), input);
|
||||
|
||||
return LEXER_STATE_ESCAPE_SEQUENCE;
|
||||
case '"':
|
||||
return LEXER_STATE_STRING_END;
|
||||
}
|
||||
|
||||
append_to_dstr(&(lexer->current_string), input);
|
||||
dstr_append(&(lexer->current_string), input);
|
||||
|
||||
return LEXER_STATE_STRING;
|
||||
}
|
||||
@@ -466,7 +466,7 @@ lexer_state_t handle_string_end(lexer_t *lexer, char input) {
|
||||
return LEXER_STATE_STRING_END;
|
||||
}
|
||||
|
||||
empty_dstr(lexer->current_string);
|
||||
dstr_clear(lexer->current_string);
|
||||
|
||||
lexer->current = stack_pop(&(lexer->stack));
|
||||
|
||||
@@ -489,7 +489,7 @@ lexer_state_t handle_string_end(lexer_t *lexer, char input) {
|
||||
}
|
||||
|
||||
lexer_state_t handle_escape_sequence(lexer_t *lexer, char input) {
|
||||
append_to_dstr(&(lexer->current_string), input);
|
||||
dstr_append(&(lexer->current_string), input);
|
||||
|
||||
switch (input) {
|
||||
case '"':
|
||||
@@ -510,7 +510,7 @@ lexer_state_t handle_escape_sequence(lexer_t *lexer, char input) {
|
||||
|
||||
lexer_state_t handle_unicode_sequence(lexer_t *lexer, char input) {
|
||||
append_to_lex_str(&(lexer->codepoint), input);
|
||||
append_to_dstr(&(lexer->current_string), input);
|
||||
dstr_append(&(lexer->current_string), input);
|
||||
|
||||
if (!ishex(input)) {
|
||||
clear_lex_str(&(lexer->codepoint));
|
||||
@@ -526,7 +526,7 @@ lexer_state_t handle_unicode_sequence(lexer_t *lexer, char input) {
|
||||
}
|
||||
|
||||
lexer_state_t handle_decimal(lexer_t *lexer, char input) {
|
||||
append_to_dstr(&(lexer->current_string), input);
|
||||
dstr_append(&(lexer->current_string), input);
|
||||
|
||||
if (input == '.') {
|
||||
return LEXER_STATE_FRACTION;
|
||||
@@ -537,19 +537,19 @@ lexer_state_t handle_decimal(lexer_t *lexer, char input) {
|
||||
|
||||
lexer_state_t handle_number(lexer_t *lexer, char input) {
|
||||
if (isdigit(input)) {
|
||||
append_to_dstr(&(lexer->current_string), input);
|
||||
dstr_append(&(lexer->current_string), input);
|
||||
|
||||
return LEXER_STATE_NUMBER;
|
||||
} else if (input == '.') {
|
||||
append_to_dstr(&(lexer->current_string), input);
|
||||
dstr_append(&(lexer->current_string), input);
|
||||
|
||||
return LEXER_STATE_FRACTION;
|
||||
} else if (input == '}' || input == ']') {
|
||||
empty_dstr(lexer->current_string);
|
||||
dstr_clear(lexer->current_string);
|
||||
|
||||
return handle_collection_end(lexer, input);
|
||||
} else if (input == ',') {
|
||||
empty_dstr(lexer->current_string);
|
||||
dstr_clear(lexer->current_string);
|
||||
|
||||
return lexer->stack.stack[lexer->stack.size - 1];
|
||||
} else if (isspace(input)) {
|
||||
@@ -561,19 +561,19 @@ lexer_state_t handle_number(lexer_t *lexer, char input) {
|
||||
|
||||
lexer_state_t handle_fraction(lexer_t *lexer, char input) {
|
||||
if (isdigit(input)) {
|
||||
append_to_dstr(&(lexer->current_string), input);
|
||||
dstr_append(&(lexer->current_string), input);
|
||||
|
||||
return LEXER_STATE_FRACTION;
|
||||
} else if (input == '}' || input == ']') {
|
||||
empty_dstr(lexer->current_string);
|
||||
dstr_clear(lexer->current_string);
|
||||
|
||||
return handle_collection_end(lexer, input);
|
||||
} else if (input == 'e' || input == 'E') {
|
||||
append_to_dstr(&(lexer->current_string), input);
|
||||
dstr_append(&(lexer->current_string), input);
|
||||
|
||||
return LEXER_STATE_EXPONENT;
|
||||
} else if (input == ',') {
|
||||
empty_dstr(lexer->current_string);
|
||||
dstr_clear(lexer->current_string);
|
||||
|
||||
return lexer->stack.stack[lexer->stack.size - 1];
|
||||
} else if (isspace(input)) {
|
||||
@@ -584,7 +584,7 @@ lexer_state_t handle_fraction(lexer_t *lexer, char input) {
|
||||
}
|
||||
|
||||
lexer_state_t handle_exponent(lexer_t *lexer, char input) {
|
||||
append_to_dstr(&(lexer->current_string), input);
|
||||
dstr_append(&(lexer->current_string), input);
|
||||
|
||||
if (isdigit(input)) {
|
||||
return LEXER_STATE_POWER;
|
||||
@@ -596,7 +596,7 @@ lexer_state_t handle_exponent(lexer_t *lexer, char input) {
|
||||
}
|
||||
|
||||
lexer_state_t handle_exp_sign(lexer_t *lexer, char input) {
|
||||
append_to_dstr(&(lexer->current_string), input);
|
||||
dstr_append(&(lexer->current_string), input);
|
||||
|
||||
if (isdigit(input)) {
|
||||
return LEXER_STATE_POWER;
|
||||
@@ -607,15 +607,15 @@ lexer_state_t handle_exp_sign(lexer_t *lexer, char input) {
|
||||
|
||||
lexer_state_t handle_power(lexer_t *lexer, char input) {
|
||||
if (isdigit(input)) {
|
||||
append_to_dstr(&(lexer->current_string), input);
|
||||
dstr_append(&(lexer->current_string), input);
|
||||
|
||||
return LEXER_STATE_POWER;
|
||||
} else if (input == '}' || input == ']') {
|
||||
empty_dstr(lexer->current_string);
|
||||
dstr_clear(lexer->current_string);
|
||||
|
||||
return handle_collection_end(lexer, input);
|
||||
} else if (input == ',') {
|
||||
empty_dstr(lexer->current_string);
|
||||
dstr_clear(lexer->current_string);
|
||||
|
||||
return lexer->stack.stack[lexer->stack.size - 1];
|
||||
} else if (isspace(input)) {
|
||||
@@ -626,7 +626,7 @@ lexer_state_t handle_power(lexer_t *lexer, char input) {
|
||||
}
|
||||
|
||||
lexer_state_t handle_number_end(lexer_t *lexer, char input) {
|
||||
empty_dstr(lexer->current_string);
|
||||
dstr_clear(lexer->current_string);
|
||||
|
||||
if (isspace(input)) {
|
||||
return LEXER_STATE_NUMBER_END;
|
||||
|
||||
Reference in New Issue
Block a user