TokenString Empty test passes
This commit is contained in:
parent
eacef33cf8
commit
febf34a737
|
|
@ -646,7 +646,27 @@ static LexerResult parse_string_literal(LexerInfo *lexer_info, char c, size_t st
|
||||||
return (LexerResult){SLS_ERROR, .error = (SlsError){SLS_STR("Lexer: String Literals Not Implemented Error."), 1}};
|
return (LexerResult){SLS_ERROR, .error = (SlsError){SLS_STR("Lexer: String Literals Not Implemented Error."), 1}};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void skip_comments_and_whitespace(LexerInfo *lexer_info) {
|
||||||
|
while (isspace(peek(lexer_info)) || peek(lexer_info) == '/' || peek(lexer_info) == '#') {
|
||||||
|
// Skip Comments
|
||||||
|
if ((peek(lexer_info) == '/' && far_peek(lexer_info, 1) == '/') || peek(lexer_info) == '#')
|
||||||
|
while (!(peek(lexer_info) == '\n' || peek(lexer_info) == '\0'))
|
||||||
|
advance(lexer_info);
|
||||||
|
// Skip whitespace
|
||||||
|
while (isspace(peek(lexer_info))) advance(lexer_info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static LexerResult parse_token_string(LexerInfo *lexer_info, char c, size_t start, size_t start_line) {
|
static LexerResult parse_token_string(LexerInfo *lexer_info, char c, size_t start, size_t start_line) {
|
||||||
|
advance(lexer_info);
|
||||||
|
skip_comments_and_whitespace(lexer_info);
|
||||||
|
c = peek(lexer_info);
|
||||||
|
if (c == '}') {
|
||||||
|
advance(lexer_info);
|
||||||
|
return lexer_result(lexer_info, (Token){TOKEN_TOKEN_STRING, .token_string = (TokenString){NULL, 0}}, start, start_line);
|
||||||
|
}
|
||||||
|
if (c == '\0')
|
||||||
|
return lexer_error(lexer_info, SLS_STR("Unclosed token string: missing closing brace '}'."), start, start_line);
|
||||||
(void)lexer_info; (void)c; (void)start; (void)start_line;
|
(void)lexer_info; (void)c; (void)start; (void)start_line;
|
||||||
return (LexerResult){SLS_ERROR, .error = (SlsError){SLS_STR("Lexer: Token Strings Not Implemented Error."), 1}};
|
return (LexerResult){SLS_ERROR, .error = (SlsError){SLS_STR("Lexer: Token Strings Not Implemented Error."), 1}};
|
||||||
}
|
}
|
||||||
|
|
@ -720,14 +740,7 @@ static LexerResult parse_identifiers_and_booleans(LexerInfo *lexer_info, char c,
|
||||||
static LexerResult lexer_next(LexerInfo *lexer_info) {
|
static LexerResult lexer_next(LexerInfo *lexer_info) {
|
||||||
// Gets the next token from the source
|
// Gets the next token from the source
|
||||||
|
|
||||||
while (isspace(peek(lexer_info)) || peek(lexer_info) == '/' || peek(lexer_info) == '#') {
|
skip_comments_and_whitespace(lexer_info);
|
||||||
// Skip Comments
|
|
||||||
if ((peek(lexer_info) == '/' && far_peek(lexer_info, 1) == '/') || peek(lexer_info) == '#')
|
|
||||||
while (!(peek(lexer_info) == '\n' || peek(lexer_info) == '\0'))
|
|
||||||
advance(lexer_info);
|
|
||||||
// Skip whitespace
|
|
||||||
while (isspace(peek(lexer_info))) advance(lexer_info);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize begining variables
|
// Initialize begining variables
|
||||||
char c = peek(lexer_info);
|
char c = peek(lexer_info);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue