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.
 

Function Documentation

◆ 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
14 dstring_init(&token->lexeme, 25); // 25 is big enough to fit the major of the tokens.
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:46
Struct for a Mya token.
Definition token.h:32
long long int value
Integer value of the token on TK_NUMBER tokens.
Definition token.h:36
token_type_t type
Token type.
Definition token.h:33
dstring_t lexeme
Lexeme of the token.
Definition token.h:37
unsigned int line
Token line inside the module.
Definition token.h:34
unsigned int column
Column of the token position on the line.
Definition token.h:35