aboutsummaryrefslogtreecommitdiff
path: root/src/include/token.h
blob: 865ba4e9ee998d01029b75e0cf3ffa86bd218d45 (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
#ifndef TOKEN_H
#define TOKEN_H

#define TOKEN_DEFNAME_FIRST_CHAR_ALLOWED_CHARS        "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_"
#define TOKEN_DEFNAME_FIRST_CHAR_ALLOWED_CHARS_LEN    53
#define TOKEN_DEFNAME_SPLIT_CHAR_ALLOWED_CHARS        "1234567890_-"
#define TOKEN_DEFNAME_SPLIT_CHAR_ALLOWED_CHARS_LEN    12
#define TOKEN_CHAR_IGNORE                             " \t\n\r"
#define TOKEN_CHAR_IGNORE_LEN                         4
#define TOKEN_CHAR_FIRST_CHAR_INT                     "0123456789"


typedef struct TOKEN_STRUC {
   enum TOKEN_ENUM {
      TOKEN_KEYWORD,             // keyword
      TOKEN_PRIM_STR_DELIM,      // '
      TOKEN_PRIM_STR,            // 'string'
      TOKEN_PRIM_INT,            // 42
      TOKEN_COMM_DELIM,          // `
      TOKEN_COMM,                // `comment`
      TOKEN_EXPR_END,            // ;
      TOKEN_LGROUP,              // (
      TOKEN_RGROUP,              // )
      TOKEN_DIRECTIVE_DELIM,     // #
      TOKEN_DIRECTIVE,           // #DIRECTIVE#
      TOKEN_FN_APPLY,            // .
      TOKEN_LIST_DELIM,          // ,
      TOKEN_DEF_TAGS_DELIM,      // :
      TOKEN_DEF,                 // def:def
      TOKEN_BLOCK_DELIM_START,   // {
      TOKEN_BLOCK_DELIM_END,     // }
      TOKEN_NAMESPACE_DELIM,     // /
      TOKEN_ARRAY_DELIM_START,   // [
      TOKEN_ARRAY_DELIM_END,     // ]
      TOKEN_DEF_SET,             // =
      TOKEN_EOF,                 // \0
    } type;

    char* value;
} token_t;

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

int char_could_start_keyword(char* character);
int char_could_split_keyword(char* character);
int char_could_start_int(char* character);
int char_can_ignore(char* character);


#endif