Libcroco
Data Structures | Typedefs | Functions
cr-tknzr.h File Reference
#include "cr-utils.h"
#include "cr-input.h"
#include "cr-token.h"

Go to the source code of this file.

Data Structures

struct  _CRTknzr
 The tokenizer is the class that knows about all the css token. More...
 

Typedefs

typedef typedefG_BEGIN_DECLS struct _CRTknzr CRTknzr
 
typedef struct _CRTknzrPriv CRTknzrPriv
 

Functions

CRTknzrcr_tknzr_new (CRInput *a_input)
 
CRTknzrcr_tknzr_new_from_uri (const guchar *a_file_uri, enum CREncoding a_enc)
 
CRTknzrcr_tknzr_new_from_buf (guchar *a_buf, gulong a_len, enum CREncoding a_enc, gboolean a_free_at_destroy)
 
gboolean cr_tknzr_unref (CRTknzr *a_this)
 
void cr_tknzr_ref (CRTknzr *a_this)
 
enum CRStatus cr_tknzr_read_byte (CRTknzr *a_this, guchar *a_byte)
 Reads the next byte from the parser input stream. More...
 
enum CRStatus cr_tknzr_read_char (CRTknzr *a_this, guint32 *a_char)
 Reads the next char from the parser input stream. More...
 
enum CRStatus cr_tknzr_peek_char (CRTknzr *a_this, guint32 *a_char)
 Peeks a char from the parser input stream. More...
 
enum CRStatus cr_tknzr_peek_byte (CRTknzr *a_this, gulong a_offset, guchar *a_byte)
 Peeks a byte ahead at a given postion in the parser input stream. More...
 
guchar cr_tknzr_peek_byte2 (CRTknzr *a_this, gulong a_offset, gboolean *a_eof)
 Same as cr_tknzr_peek_byte() but this api returns the byte peeked. More...
 
enum CRStatus cr_tknzr_set_cur_pos (CRTknzr *a_this, CRInputPos *a_pos)
 
glong cr_tknzr_get_nb_bytes_left (CRTknzr *a_this)
 Gets the number of bytes left in the topmost input stream associated to this parser. More...
 
enum CRStatus cr_tknzr_get_cur_pos (CRTknzr *a_this, CRInputPos *a_pos)
 
enum CRStatus cr_tknzr_get_parsing_location (CRTknzr *a_this, CRParsingLocation *a_loc)
 
enum CRStatus cr_tknzr_seek_index (CRTknzr *a_this, enum CRSeekPos a_origin, gint a_pos)
 
enum CRStatus cr_tknzr_get_cur_byte_addr (CRTknzr *a_this, guchar **a_addr)
 
enum CRStatus cr_tknzr_consume_chars (CRTknzr *a_this, guint32 a_char, glong *a_nb_char)
 
enum CRStatus cr_tknzr_get_next_token (CRTknzr *a_this, CRToken **a_tk)
 Returns the next token of the input stream. More...
 
enum CRStatus cr_tknzr_unget_token (CRTknzr *a_this, CRToken *a_token)
 
enum CRStatus cr_tknzr_parse_token (CRTknzr *a_this, enum CRTokenType a_type, enum CRTokenExtraType a_et, gpointer a_res, gpointer a_extra_res)
 
enum CRStatus cr_tknzr_set_input (CRTknzr *a_this, CRInput *a_input)
 
enum CRStatus cr_tknzr_get_input (CRTknzr *a_this, CRInput **a_input)
 
void cr_tknzr_destroy (CRTknzr *a_this)
 

Detailed Description

The declaration of the CRTknzr (tokenizer) class.

Definition in file cr-tknzr.h.

Typedef Documentation

◆ CRTknzr

typedef typedefG_BEGIN_DECLS struct _CRTknzr CRTknzr

Definition at line 40 of file cr-tknzr.h.

◆ CRTknzrPriv

typedef struct _CRTknzrPriv CRTknzrPriv

Definition at line 41 of file cr-tknzr.h.

Function Documentation

◆ cr_tknzr_consume_chars()

enum CRStatus cr_tknzr_consume_chars ( CRTknzr a_this,
guint32  a_char,
glong *  a_nb_char 
)

◆ cr_tknzr_destroy()

void cr_tknzr_destroy ( CRTknzr a_this)

Definition at line 2740 of file cr-tknzr.c.

References cr_input_unref(), cr_token_destroy(), and PRIVATE.

Referenced by cr_tknzr_unref().

◆ cr_tknzr_get_cur_byte_addr()

enum CRStatus cr_tknzr_get_cur_byte_addr ( CRTknzr a_this,
guchar **  a_addr 
)

◆ cr_tknzr_get_cur_pos()

enum CRStatus cr_tknzr_get_cur_pos ( CRTknzr a_this,
CRInputPos a_pos 
)

◆ cr_tknzr_get_input()

enum CRStatus cr_tknzr_get_input ( CRTknzr a_this,
CRInput **  a_input 
)

Definition at line 1701 of file cr-tknzr.c.

References CR_BAD_PARAM_ERROR, CR_OK, and PRIVATE.

◆ cr_tknzr_get_nb_bytes_left()

glong cr_tknzr_get_nb_bytes_left ( CRTknzr a_this)

Gets the number of bytes left in the topmost input stream associated to this parser.

Parameters
a_thisthe current instance of CRTknzr
Returns
the number of bytes left or -1 in case of error.

Definition at line 1834 of file cr-tknzr.c.

References CR_BAD_PARAM_ERROR, cr_input_get_nb_bytes_left(), cr_input_set_cur_pos(), cr_token_destroy(), and PRIVATE.

◆ cr_tknzr_get_next_token()

enum CRStatus cr_tknzr_get_next_token ( CRTknzr a_this,
CRToken **  a_tk 
)

Returns the next token of the input stream.

This method is really central. Each parsing method calls it.

Parameters
a_thisthe current tokenizer.
a_tkout parameter. The returned token. for the sake of mem leak avoidance, *a_tk must be NULL.
CR_OKupon successfull completion, an error code otherwise.

Definition at line 1969 of file cr-tknzr.c.

References CR_BAD_PARAM_ERROR, CR_END_OF_INPUT_ERROR, cr_input_get_end_of_file(), CR_OK, ENSURE_PARSING_COND, PRIVATE, and RECORD_INITIAL_POS.

Referenced by cr_parser_parse_charset(), cr_parser_parse_font_face(), cr_parser_parse_media(), cr_parser_parse_page(), cr_parser_parse_prio(), cr_parser_parse_statement_core(), cr_parser_parse_term(), cr_parser_try_to_skip_spaces_and_comments(), and cr_tknzr_parse_token().

◆ cr_tknzr_get_parsing_location()

enum CRStatus cr_tknzr_get_parsing_location ( CRTknzr a_this,
CRParsingLocation a_loc 
)

Definition at line 1867 of file cr-tknzr.c.

References CR_BAD_PARAM_ERROR, cr_input_get_parsing_location(), and PRIVATE.

Referenced by cr_parser_get_parsing_location().

◆ cr_tknzr_new()

CRTknzr* cr_tknzr_new ( CRInput a_input)

◆ cr_tknzr_new_from_buf()

CRTknzr* cr_tknzr_new_from_buf ( guchar *  a_buf,
gulong  a_len,
enum CREncoding  a_enc,
gboolean  a_free_at_destroy 
)

Definition at line 1627 of file cr-tknzr.c.

References cr_input_new_from_buf(), and cr_tknzr_new().

Referenced by cr_parser_parse_buf().

◆ cr_tknzr_new_from_uri()

CRTknzr* cr_tknzr_new_from_uri ( const guchar *  a_file_uri,
enum CREncoding  a_enc 
)

Definition at line 1645 of file cr-tknzr.c.

References cr_input_new_from_uri(), and cr_tknzr_new().

Referenced by cr_parser_new_from_file(), and cr_parser_parse_file().

◆ cr_tknzr_parse_token()

enum CRStatus cr_tknzr_parse_token ( CRTknzr a_this,
enum CRTokenType  a_type,
enum CRTokenExtraType  a_et,
gpointer  a_res,
gpointer  a_extra_res 
)

◆ cr_tknzr_peek_byte()

enum CRStatus cr_tknzr_peek_byte ( CRTknzr a_this,
gulong  a_offset,
guchar *  a_byte 
)

Peeks a byte ahead at a given postion in the parser input stream.

Parameters
a_thisthe current instance of CRTknzr.
a_offsetthe offset of the peeked byte starting from the current byte in the parser input stream.
a_byteout parameter. The peeked byte upon successfull completion.
Returns
CR_OK upon successfull completion, an error code otherwise.

Definition at line 1791 of file cr-tknzr.c.

References CR_BAD_PARAM_ERROR, cr_input_peek_byte(), cr_input_set_cur_pos(), CR_SEEK_CUR, cr_token_destroy(), and PRIVATE.

Referenced by cr_parser_parse_expr().

◆ cr_tknzr_peek_byte2()

guchar cr_tknzr_peek_byte2 ( CRTknzr a_this,
gulong  a_offset,
gboolean *  a_eof 
)

Same as cr_tknzr_peek_byte() but this api returns the byte peeked.

Parameters
a_thisthe current instance of CRTknzr.
a_offsetthe offset of the peeked byte starting from the current byte in the parser input stream.
a_eofout parameter. If not NULL, is set to TRUE if we reached end of file, FALE otherwise. If the caller sets it to NULL, this parameter is just ignored.
Returns
the peeked byte.

Definition at line 1819 of file cr-tknzr.c.

References cr_input_peek_byte2(), and PRIVATE.

◆ cr_tknzr_peek_char()

enum CRStatus cr_tknzr_peek_char ( CRTknzr a_this,
guint32 *  a_char 
)

Peeks a char from the parser input stream.

To "peek a char" means reads the next char without consuming it. Subsequent calls to this function return the same char.

Parameters
a_thisthe current instance of CRTknzr.
a_charout parameter. The peeked char uppon successfull completion.
Returns
CR_OK upon successfull completion, an error code otherwise.

Definition at line 1765 of file cr-tknzr.c.

References CR_BAD_PARAM_ERROR, cr_input_peek_char(), cr_input_set_cur_pos(), cr_token_destroy(), and PRIVATE.

◆ cr_tknzr_read_byte()

enum CRStatus cr_tknzr_read_byte ( CRTknzr a_this,
guchar *  a_byte 
)

Reads the next byte from the parser input stream.

Parameters
a_thisthe "this pointer" of the current instance of CRParser.
a_byteout parameter the place where to store the byte read.
Returns
CR_OK upon successfull completion, an error code otherwise.

Definition at line 1724 of file cr-tknzr.c.

References CR_BAD_PARAM_ERROR, cr_input_read_byte(), and PRIVATE.

◆ cr_tknzr_read_char()

enum CRStatus cr_tknzr_read_char ( CRTknzr a_this,
guint32 *  a_char 
)

Reads the next char from the parser input stream.

Parameters
a_thisthe current instance of CRTknzr.
a_charout parameter. The read char.
Returns
CR_OK upon successfull completion, an error code otherwise.

Definition at line 1740 of file cr-tknzr.c.

References CR_BAD_PARAM_ERROR, cr_input_read_char(), cr_input_set_cur_pos(), cr_token_destroy(), and PRIVATE.

◆ cr_tknzr_ref()

void cr_tknzr_ref ( CRTknzr a_this)

Definition at line 1660 of file cr-tknzr.c.

References PRIVATE.

Referenced by cr_parser_set_tknzr().

◆ cr_tknzr_seek_index()

enum CRStatus cr_tknzr_seek_index ( CRTknzr a_this,
enum CRSeekPos  a_origin,
gint  a_pos 
)

◆ cr_tknzr_set_cur_pos()

enum CRStatus cr_tknzr_set_cur_pos ( CRTknzr a_this,
CRInputPos a_pos 
)

Definition at line 1932 of file cr-tknzr.c.

References CR_BAD_PARAM_ERROR, cr_input_set_cur_pos(), cr_token_destroy(), and PRIVATE.

◆ cr_tknzr_set_input()

enum CRStatus cr_tknzr_set_input ( CRTknzr a_this,
CRInput a_input 
)

Definition at line 1685 of file cr-tknzr.c.

References CR_BAD_PARAM_ERROR, cr_input_ref(), cr_input_unref(), CR_OK, and PRIVATE.

Referenced by cr_tknzr_new().

◆ cr_tknzr_unget_token()

enum CRStatus cr_tknzr_unget_token ( CRTknzr a_this,
CRToken a_token 
)

Definition at line 1946 of file cr-tknzr.c.

References CR_BAD_PARAM_ERROR, CR_OK, and PRIVATE.

Referenced by cr_parser_parse_page(), and cr_parser_parse_statement_core().

◆ cr_tknzr_unref()

gboolean cr_tknzr_unref ( CRTknzr a_this)

Definition at line 1668 of file cr-tknzr.c.

References cr_tknzr_destroy(), and PRIVATE.

Referenced by cr_parser_destroy(), and cr_parser_set_tknzr().