From 72c39e3522c5781d1e7dc8abad77d96141c5d49b Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Thu, 1 May 2008 16:36:27 +0000 Subject: Import beginnings of a CSS parsing library. Currently comprises a lexer. svn path=/trunk/libcss/; revision=4112 --- src/lex/lex.h | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 src/lex/lex.h (limited to 'src/lex/lex.h') 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 + */ + +#ifndef css_lex_lex_h_ +#define css_lex_lex_h_ + +#include +#include + +#include + +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 + -- cgit v1.2.3