File: tokenizer.h

package info (click to toggle)
ruby-liquid-c 4.2.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 504 kB
  • sloc: ansic: 3,866; ruby: 1,151; makefile: 7
file content (47 lines) | stat: -rw-r--r-- 1,175 bytes parent folder | download | duplicates (2)
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
#if !defined(LIQUID_TOKENIZER_H)
#define LIQUID_TOKENIZER_H

enum token_type {
    TOKENIZER_TOKEN_NONE = 0,
    TOKEN_INVALID,
    TOKEN_RAW,
    TOKEN_TAG,
    TOKEN_VARIABLE,
    TOKEN_BLANK_LIQUID_TAG_LINE
};

typedef struct token {
    enum token_type type;

    // str_trimmed contains no tag delimiters
    const char *str_trimmed, *str_full;
    long len_trimmed, len_full;

    bool lstrip, rstrip;
} token_t;

typedef struct tokenizer {
    VALUE source;
    const char *cursor, *cursor_end;
    unsigned int line_number;
    bool lstrip_flag;
    bool for_liquid_tag;

    // Temporary to test rollout of the fix for this bug
    bool bug_compatible_whitespace_trimming;

    char *raw_tag_body;
    unsigned int raw_tag_body_len;
} tokenizer_t;

extern VALUE cLiquidTokenizer;
extern const rb_data_type_t tokenizer_data_type;
#define Tokenizer_Get_Struct(obj, sval) TypedData_Get_Struct(obj, tokenizer_t, &tokenizer_data_type, sval)

void liquid_define_tokenizer(void);
void tokenizer_next(tokenizer_t *tokenizer, token_t *token);

void tokenizer_setup_for_liquid_tag(tokenizer_t *tokenizer, const char *cursor, const char *cursor_end, int line_number);

#endif