31
31
/* These are currently not used in the lexical specification, but a token
32
32
* is assigned to these to generate proper error messages (these are
33
33
* technically not garbage and possibly part of mistyped but otherwise
40
STT_GARBAGE, /* Error reporting deferred to parser */
41
STT_ERROR /* Lexer is responsible for error, parser won't report additional
40
STT_GARBAGE, /* Error reporting deferred to parser */
41
STT_ERROR /* Lexer is responsible for error, parser won't report additional
61
61
const struct sieve_lexer *sieve_lexer_create
62
(struct sieve_script *script, struct sieve_error_handler *ehandler,
62
(struct sieve_script *script, struct sieve_error_handler *ehandler,
63
63
enum sieve_error *error_r);
64
64
void sieve_lexer_free(const struct sieve_lexer **lexer);
70
70
bool sieve_lexer_skip_token(const struct sieve_lexer *lexer);
76
76
static inline enum sieve_token_type sieve_lexer_token_type
77
(const struct sieve_lexer *lexer)
77
(const struct sieve_lexer *lexer)
79
79
return lexer->token_type;
82
82
static inline const string_t *sieve_lexer_token_str
83
(const struct sieve_lexer *lexer)
83
(const struct sieve_lexer *lexer)
85
85
i_assert( lexer->token_type == STT_STRING );
87
87
return lexer->token_str_value;
90
90
static inline const char *sieve_lexer_token_ident
91
(const struct sieve_lexer *lexer)
91
(const struct sieve_lexer *lexer)
94
94
lexer->token_type == STT_TAG ||
95
95
lexer->token_type == STT_IDENTIFIER);
97
97
return str_c(lexer->token_str_value);
100
100
static inline int sieve_lexer_token_int
101
(const struct sieve_lexer *lexer)
101
(const struct sieve_lexer *lexer)
103
103
i_assert(lexer->token_type == STT_NUMBER);
105
105
return lexer->token_int_value;
108
108
static inline bool sieve_lexer_eof
109
(const struct sieve_lexer *lexer)
109
(const struct sieve_lexer *lexer)
111
111
return lexer->token_type == STT_EOF;
114
114
static inline int sieve_lexer_token_line
115
(const struct sieve_lexer *lexer)
115
(const struct sieve_lexer *lexer)
117
117
return lexer->token_line;