lang: lex: add definitions for some missing symbols and keywords
This commit is contained in:
@@ -34,6 +34,7 @@ enum ivy_keyword {
|
||||
IVY_KW_IF,
|
||||
IVY_KW_AND,
|
||||
IVY_KW_OR,
|
||||
IVY_KW_UNDERSTANDS,
|
||||
IVY_KW_IS,
|
||||
IVY_KW_NOT,
|
||||
IVY_KW_ELSE,
|
||||
@@ -87,6 +88,7 @@ enum ivy_symbol {
|
||||
IVY_SYM_PIPE_EQUAL,
|
||||
IVY_SYM_PERCENT_EQUAL,
|
||||
IVY_SYM_CARET_EQUAL,
|
||||
IVY_SYM_BANG_EQUAL,
|
||||
IVY_SYM_HASH,
|
||||
IVY_SYM_BANG,
|
||||
IVY_SYM_PIPE,
|
||||
@@ -130,6 +132,14 @@ IVY_API struct ivy_token *ivy_lexer_peek(struct ivy_lexer *lex);
|
||||
IVY_API struct ivy_token *ivy_lexer_read(struct ivy_lexer *lex);
|
||||
IVY_API bool ivy_lexer_tokens_available(struct ivy_lexer *lex);
|
||||
|
||||
static inline bool ivy_token_is_symbol(struct ivy_token *tok, enum ivy_symbol sym)
|
||||
{
|
||||
return (tok->t_type == IVY_TOK_SYMBOL && tok->t_symbol == sym);
|
||||
}
|
||||
static inline bool ivy_token_is_keyword(struct ivy_token *tok, enum ivy_keyword kw)
|
||||
{
|
||||
return (tok->t_type == IVY_TOK_KEYWORD && tok->t_keyword == kw);
|
||||
}
|
||||
IVY_API void ivy_token_destroy(struct ivy_token *tok);
|
||||
|
||||
IVY_API const char *ivy_lex_token_type_to_string(enum ivy_token_type type);
|
||||
|
||||
@@ -28,6 +28,7 @@ static struct lex_token_def keywords[] = {
|
||||
LEX_TOKEN_DEF(IVY_KW_TRY, "try"),
|
||||
LEX_TOKEN_DEF(IVY_KW_THROW, "throw"),
|
||||
LEX_TOKEN_DEF(IVY_KW_CATCH, "catch"),
|
||||
LEX_TOKEN_DEF(IVY_KW_UNDERSTANDS, "understands"),
|
||||
LEX_TOKEN_DEF(IVY_KW_IF, "if"),
|
||||
LEX_TOKEN_DEF(IVY_KW_AND, "and"),
|
||||
LEX_TOKEN_DEF(IVY_KW_OR, "or"),
|
||||
@@ -85,6 +86,7 @@ static struct lex_token_def symbols[] = {
|
||||
LEX_TOKEN_DEF(IVY_SYM_PIPE_EQUAL, "|="),
|
||||
LEX_TOKEN_DEF(IVY_SYM_PERCENT_EQUAL, "%="),
|
||||
LEX_TOKEN_DEF(IVY_SYM_CARET_EQUAL, "^="),
|
||||
LEX_TOKEN_DEF(IVY_SYM_BANG_EQUAL, "!="),
|
||||
LEX_TOKEN_DEF(IVY_SYM_HASH, "#"),
|
||||
LEX_TOKEN_DEF(IVY_SYM_BANG, "!"),
|
||||
LEX_TOKEN_DEF(IVY_SYM_PIPE, "|"),
|
||||
|
||||
Reference in New Issue
Block a user