diff options
author | c+1 | 2023-05-03 12:55:24 -0400 |
---|---|---|
committer | c+1 | 2023-05-03 12:55:24 -0400 |
commit | 223a6730d50ebdced0fec779018207b591474022 (patch) | |
tree | 1ef06925d6b6b6068e6723ebd0ad7988b905dfe0 /src | |
parent | 84c4528068399fac2610680f643adf3cf6c36519 (diff) |
special characters
Diffstat (limited to 'src')
-rw-r--r-- | src/lexer.c | 62 |
1 files changed, 61 insertions, 1 deletions
diff --git a/src/lexer.c b/src/lexer.c index 2a3839e..9cb3372 100644 --- a/src/lexer.c +++ b/src/lexer.c @@ -36,6 +36,66 @@ token_T* lexer_get_next_token(lexer_T* lexer) { lexer->c == '\n') { lexer_pass(lexer); } + + switch (lexer->c) { + case '"': return lexer_get_string(lexer); break; + case '=': return lexer_next_token( + lexer, + token_init( + TOKEN_EQ, + lexer_get_c_as_string(lexer) + ) + ); break; + case '/': return lexer_next_token( + lexer, + token_init( + TOKEN_LORD, + lexer_get_c_as_string(lexer) + ) + ); break; + case '\\': return lexer_next_token( + lexer, + token_init( + TOKEN_RORD, + lexer_get_c_as_string(lexer) + ) + ); break; + case '&': return lexer_next_token( + lexer, + token_init( + TOKEN_AMP, + lexer_get_c_as_string(lexer) + ) + ); break; + case '[': return lexer_next_token( + lexer, + token_init( + TOKEN_LBRAK, + lexer_get_c_as_string(lexer) + ) + ); break; + case ']': return lexer_next_token( + lexer, + token_init( + TOKEN_RBRAK, + lexer_get_c_as_string(lexer) + ) + ); break; + case '#': return lexer_next_token( + lexer, + token_init( + TOKEN_POUND, + lexer_get_c_as_string(lexer) + ) + ); break; + case '~': return lexer_next_token( + lexer, + token_init( + TOKEN_TILDE, + lexer_get_c_as_string(lexer) + ) + ); break; + } } return token_init(TOKEN_EOF, "\0"); @@ -52,7 +112,7 @@ token_T* lexer_get_id(lexer_T* lexer) { token_T* lexer_next_token(lexer_T* lexer, token_T* token) { lexer_next(lexer); - return lexer; + return token; } |