libmya 0.1.0
Library to parse Mya language.
Loading...
Searching...
No Matches
token.c
Go to the documentation of this file.
1#include <string.h>
2
3#include "dstring.h"
4#include "token.h"
5
6void
7token_init(token_t* token, const char* lexeme, token_type_t type, unsigned int line, unsigned int column)
8{
9 token->type = type;
10 token->line = line;
11 token->column = column;
12 token->value = 0;
13
15 dstring_copy(&token->lexeme, lexeme);
16}
17
18void
void dstring_init(dstring_t *string, unsigned int buffer_size)
Initializes a dynamic string (dstring).
Definition dstring.c:10
void dstring_copy(dstring_t *string, const char *source)
Copies the content of source to the dstring.
Definition dstring.c:50
void dstring_close(dstring_t *string)
Closes the dynamic string.
Definition dstring.c:18
Struct for a Mya token.
Definition token.h:34
long long int value
Integer value of the token.
Definition token.h:38
token_type_t type
Token type.
Definition token.h:35
dstring_t lexeme
Lexeme of the token.
Definition token.h:41
unsigned int line
Token line inside the module.
Definition token.h:36
unsigned int column
Column of the token position on the line.
Definition token.h:37
void token_close(token_t *token)
Closes the given token.
Definition token.c:19
void token_init(token_t *token, const char *lexeme, token_type_t type, unsigned int line, unsigned int column)
Initializes a token struct.
Definition token.c:7
enum token_type token_type_t
Enumeration of token types.
struct token token_t
Struct for a Mya token.