diff options
author | John Mark Bell <jmb@netsurf-browser.org> | 2008-05-01 16:36:27 +0000 |
---|---|---|
committer | John Mark Bell <jmb@netsurf-browser.org> | 2008-05-01 16:36:27 +0000 |
commit | 72c39e3522c5781d1e7dc8abad77d96141c5d49b (patch) | |
tree | e16497caaa0bf20771ef34787de02fc95e5993bf /src/lex/lex.h | |
download | libcss-72c39e3522c5781d1e7dc8abad77d96141c5d49b.tar.gz libcss-72c39e3522c5781d1e7dc8abad77d96141c5d49b.tar.bz2 |
Import beginnings of a CSS parsing library.
Currently comprises a lexer.
svn path=/trunk/libcss/; revision=4112
Diffstat (limited to 'src/lex/lex.h')
-rw-r--r-- | src/lex/lex.h | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/src/lex/lex.h b/src/lex/lex.h new file mode 100644 index 0000000..150823e --- /dev/null +++ b/src/lex/lex.h @@ -0,0 +1,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 + |