Added TOKEN_PP_USE to lexer with implementation
This commit is contained in:
10
asm/lexer.c
10
asm/lexer.c
@@ -24,6 +24,8 @@ const char *token_type_as_cstr(token_type_t type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case TOKEN_PP_USE:
|
||||
return "PP_USE";
|
||||
case TOKEN_PP_CONST:
|
||||
return "PP_CONST";
|
||||
case TOKEN_PP_END:
|
||||
@@ -180,6 +182,11 @@ lerr_t tokenise_symbol(buffer_t *buffer, size_t *column, token_t *token)
|
||||
type = TOKEN_PP_CONST;
|
||||
offset = 6;
|
||||
}
|
||||
else if (sym_size == 4 && strncmp(opcode + 1, "USE", 3) == 0)
|
||||
{
|
||||
type = TOKEN_PP_USE;
|
||||
offset = 4;
|
||||
}
|
||||
else if (sym_size == 4 && strncmp(opcode + 1, "END", 3) == 0)
|
||||
{
|
||||
type = TOKEN_PP_END;
|
||||
@@ -599,8 +606,7 @@ lerr_t tokenise_buffer(buffer_t *buffer, token_stream_t *tokens_ptr)
|
||||
darr_append_bytes(&tokens, (byte *)&t, sizeof(t));
|
||||
}
|
||||
}
|
||||
size_t n_tokens = tokens.used / sizeof(token_t);
|
||||
tokens.available = n_tokens;
|
||||
tokens.available = tokens.used / sizeof(token_t);
|
||||
tokens.used = 0;
|
||||
*tokens_ptr = tokens;
|
||||
return LERR_OK;
|
||||
|
||||
@@ -17,9 +17,10 @@
|
||||
|
||||
typedef enum TokenType
|
||||
{
|
||||
TOKEN_PP_CONST,
|
||||
TOKEN_PP_END,
|
||||
TOKEN_PP_REFERENCE,
|
||||
TOKEN_PP_CONST, // %const(<symbol>)...
|
||||
TOKEN_PP_USE, // %use <string>
|
||||
TOKEN_PP_END, // %end
|
||||
TOKEN_PP_REFERENCE, // $<symbol>
|
||||
TOKEN_GLOBAL,
|
||||
TOKEN_STAR,
|
||||
TOKEN_LITERAL_NUMBER,
|
||||
|
||||
Reference in New Issue
Block a user