aboutsummaryrefslogtreecommitdiff
path: root/src/include/token.h
blob: 9e64c979026033ad50509856f636e3509d71e553 (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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#ifndef TOKEN_H
#define TOKEN_H

#include "util.h"
#include "hlkt.h"

/* token struct */
typedef struct TOKEN_STRUC {
   /* token type */
   enum TOKEN_TYPE {
      TOKEN_UNKNOWN,
      TOKEN_CHAR,
      TOKEN_STR,
      TOKEN_EXPR_END,
      TOKEN_SET,
      TOKEN_LGROUP,
      TOKEN_RGROUP,
      TOKEN_APPLY,
      TOKEN_LIST_DELIM,
      TOKEN_TAG,
      TOKEN_NAMESPACE_DELIM,
      TOKEN_LBLOCK,
      TOKEN_RBLOCK,
      TOKEN_RLIST,
      TOKEN_LLIST,
      TOKEN_ESC,
      TOKEN_KWD,
      TOKEN_INT
   } type;

   /* token value */
   char* val;

   /* next token */
   struct TOKEN_STRUC* nxt;
} token_t;

/* creates a token */
token_t* token_init(int type, char val);
/* destroys a token **and all tokens contained in nxt** **Make sure to set the nxt of any parent tokens to NULL** */
void token_destroy(token_t* token);

/* return pointer to the last token */
token_t* token_last(token_t* token);
/* add a character to the token value */
void token_add_char(token_t*, char);

/* print a token -- for debugging purposes */
void token_print(token_t* token);

#endif