aboutsummaryrefslogtreecommitdiff
path: root/src/token.c
blob: 26af59863bc5045e1077c1637af3a4e43fbe910f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <stdlib.h>

#include "include/token.h"

token_t* token_init(int type, char* val) {
   token_t* token;

   token = emalloc(sizeof(struct TOKEN_STRUC));
   token->type = type;
   token->val = val;
   token->nxt = NULL;

   return token;
}

void token_destroy(token_t* token) {
   free(token);
}

token_t* token_last(token_t* token) {
   token_t* t;

   while (t->nxt) {
      t = t->nxt;
   }

   return t;
}