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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
/*
* This file is part of LibCSS.
* Licensed under the MIT License,
* http://www.opensource.org/licenses/mit-license.php
* Copyright 2008 John-Mark Bell <jmb@netsurf-browser.org>
*/
#ifndef css_lex_lex_h_
#define css_lex_lex_h_
#include <libcss/functypes.h>
#include <libcss/types.h>
#include <parserutils/input/inputstream.h>
typedef struct css_lexer css_lexer;
/**
* Lexer option types
*/
typedef enum css_lexer_opttype {
CSS_LEXER_EMIT_COMMENTS,
} css_lexer_opttype;
/**
* Lexer option parameters
*/
typedef union css_lexer_optparams {
bool emit_comments;
} css_lexer_optparams;
/**
* Token type
*/
typedef enum css_token_type{
CSS_TOKEN_IDENT, CSS_TOKEN_ATKEYWORD, CSS_TOKEN_STRING,
CSS_TOKEN_HASH, CSS_TOKEN_NUMBER, CSS_TOKEN_PERCENTAGE,
CSS_TOKEN_DIMENSION, CSS_TOKEN_URI, CSS_TOKEN_UNICODE_RANGE,
CSS_TOKEN_CDO, CSS_TOKEN_CDC, CSS_TOKEN_S, CSS_TOKEN_COMMENT,
CSS_TOKEN_FUNCTION, CSS_TOKEN_INCLUDES, CSS_TOKEN_DASHMATCH,
CSS_TOKEN_PREFIXMATCH, CSS_TOKEN_SUFFIXMATCH, CSS_TOKEN_SUBSTRINGMATCH,
CSS_TOKEN_CHAR, CSS_TOKEN_EOF
} css_token_type;
/**
* Token object
*/
typedef struct css_token {
css_token_type type;
css_string data;
uint32_t col;
uint32_t line;
} css_token;
css_lexer *css_lexer_create(parserutils_inputstream *input,
css_alloc alloc, void *pw);
void css_lexer_destroy(css_lexer *lexer);
css_error css_lexer_setopt(css_lexer *lexer, css_lexer_opttype type,
css_lexer_optparams *params);
css_error css_lexer_get_token(css_lexer *lexer, const css_token **token);
#endif
|