libmya 0.1.0
Library to parse Mya language.
Loading...
Searching...
No Matches
token.h File Reference
#include "types/token.h"
Include dependency graph for token.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void token_init (token_t *token, const char *lexeme, token_type_t type, unsigned int line, unsigned int column)
 Initializes a token struct.
 
void token_close (token_t *token)
 Closes the given token.
 

Function Documentation

◆ token_close()

void token_close ( token_t * token)

Closes the given token.

Parameters
tokenThe token to be closed.

Definition at line 19 of file token.c.

20{
22}
void dstring_close(dstring_t *string)
Closes the dynamic string.
Definition dstring.c:18
Struct for a Mya token.
Definition token.h:34
dstring_t lexeme
Lexeme of the token.
Definition token.h:41

◆ token_init()

void token_init ( token_t * token,
const char * lexeme,
token_type_t type,
unsigned int line,
unsigned int column )

Initializes a token struct.

Parameters
tokenThe token to be initialized.
lexemeToken's lexeme with LEXEME_MAX_SIZE maximum size.
typeToken type.
lineToken's line inside the module.
columnToken's column on line.

Definition at line 7 of file token.c.

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}
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
long long int value
Integer value of the token.
Definition token.h:38
token_type_t type
Token type.
Definition token.h:35
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