Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

cr-parser.c File Reference

The definition of the CRParser class. More...

#include "string.h"
#include "cr-parser.h"
#include "cr-num.h"
#include "cr-term.h"
#include "cr-simple-sel.h"
#include "cr-attr-sel.h"

Go to the source code of this file.

Data Structures

struct  _CRParserError
 An abstraction of an error reported by by the parsing routines. More...
struct  _CRParserPriv
 The private attributes of CRParser. More...

Defines

#define PRIVATE(obj)   ((obj)->priv)
#define CHARS_TAB_SIZE   12
#define IS_NUM(a_char)   (((a_char) >= '0' && (a_char) <= '9')?TRUE:FALSE)
 return TRUE if the character is a number ([0-9]), FALSE otherwise
#define CHECK_PARSING_STATUS(status, is_exception)
 Checks if 'status' equals CR_OK.
#define CHECK_PARSING_STATUS_ERR(a_this, a_status, a_is_exception, a_err_msg, a_err_status)
 same as CHECK_PARSING_STATUS() but this one pushes an error on the parser error stack when an error arises.
#define PEEK_NEXT_CHAR(a_this, a_to_char)
 Peeks the next char from the input stream of the current parser by invoking cr_tknzr_input_peek_char().
#define READ_NEXT_CHAR(a_this, a_to_char)
 Reads the next char from the input stream of the current parser.
#define RECORD_INITIAL_POS(a_this, a_pos)
 Gets information about the current position in the input of the parser.
#define RECORD_CUR_BYTE_ADDR(a_this, a_addr)
 Gets the address of the current byte inside the parser input.
#define PEEK_BYTE(a_parser, a_offset, a_byte_ptr)
 Peeks a byte from the topmost parser input at a given offset from the current position.
#define BYTE(a_parser, a_offset, a_eof)   cr_tknzr_peek_byte2 (PRIVATE (a_this)->tknzr, a_offset, a_eof)
#define READ_NEXT_BYTE(a_this, a_byte_ptr)
 Reads a byte from the topmost parser input steam.
#define SKIP_BYTES(a_this, a_nb_bytes)
 Skips a given number of byte in the topmost parser input.
#define SKIP_CHARS(a_parser, a_nb_chars)
 Skip utf8 encoded characters.
#define ENSURE_PARSING_COND(condition)   if (! (condition)) {status = CR_PARSING_ERROR; goto error ;}
 Tests the condition and if it is false, sets status to "CR_PARSING_ERROR" and goto the 'error' label.
#define ENSURE_PARSING_COND_ERR(a_this, a_condition, a_err_msg, a_err_status)
#define GET_NEXT_TOKEN(a_this, a_token_ptr)

Typedefs

typedef _CRParserError CRParserError

Enumerations

enum  CRParserState {
  READY_STATE = 0, TRY_PARSE_CHARSET_STATE, CHARSET_PARSED_STATE, TRY_PARSE_IMPORT_STATE,
  IMPORT_PARSED_STATE, TRY_PARSE_RULESET_STATE, RULESET_PARSED_STATE, TRY_PARSE_MEDIA_STATE,
  MEDIA_PARSED_STATE, TRY_PARSE_PAGE_STATE, PAGE_PARSED_STATE, TRY_PARSE_FONT_FACE_STATE,
  FONT_FACE_PARSED_STATE
}

Functions

enum CRStatus cr_parser_try_to_skip_spaces_and_comments (CRParser *a_this)
 Same as cr_parser_try_to_skip_spaces() but this one skips spaces and comments.
enum CRStatus cr_parser_parse_term (CRParser *a_this, CRTerm **a_term)
 Parses a "term" as defined in the css2 spec, appendix D.1: term ::= unary_operator? [NUMBER S* | PERCENTAGE S* | LENGTH S* | EMS S* | EXS S* | ANGLE S* | TIME S* | FREQ S* | function ] | STRING S* | IDENT S* | URI S* | RGB S* | UNICODERANGE S* | hexcolor.
CRParsercr_parser_new (CRTknzr *a_tknzr)
 Creates a new parser to parse data coming the input stream given in parameter.
CRParsercr_parser_new_from_buf (guchar *a_buf, gulong a_len, enum CREncoding a_enc, gboolean a_free_buf)
 Instanciates a new parser from a memory buffer.
CRParsercr_parser_new_from_input (CRInput *a_input)
CRParsercr_parser_new_from_file (const guchar *a_file_uri, enum CREncoding a_enc)
enum CRStatus cr_parser_set_sac_handler (CRParser *a_this, CRDocHandler *a_handler)
 Sets a SAC document handler to the parser.
enum CRStatus cr_parser_get_sac_handler (CRParser *a_this, CRDocHandler **a_handler)
 Gets the SAC document handler.
enum CRStatus cr_parser_set_default_sac_handler (CRParser *a_this)
 Sets the SAC handler associated to the current instance of CRParser to the default SAC handler.
enum CRStatus cr_parser_set_use_core_grammar (CRParser *a_this, gboolean a_use_core_grammar)
enum CRStatus cr_parser_get_use_core_grammar (CRParser *a_this, gboolean *a_use_core_grammar)
enum CRStatus cr_parser_parse_file (CRParser *a_this, const guchar *a_file_uri, enum CREncoding a_enc)
 Parses a the given in parameter.
enum CRStatus cr_parser_parse_expr (CRParser *a_this, CRTerm **a_expr)
 Parses an expression as defined by the css2 spec in appendix D.1: expr: term [ operator term ]*.
enum CRStatus cr_parser_parse_prio (CRParser *a_this, CRString **a_prio)
 Parses a declaration priority as defined by the css2 grammar in appendix C: prio: IMPORTANT_SYM S*.
enum CRStatus cr_parser_parse_declaration (CRParser *a_this, CRString **a_property, CRTerm **a_expr, gboolean *a_important)
 TODO: return the parsed priority, so that upper layers can take benefit from it.
enum CRStatus cr_parser_parse_statement_core (CRParser *a_this)
 Parses a statement as defined by the css core grammar in chapter 4.1 of the css2 spec.
enum CRStatus cr_parser_parse_ruleset (CRParser *a_this)
 Parses a "ruleset" as defined in the css2 spec at appendix D.1.
enum CRStatus cr_parser_parse_import (CRParser *a_this, GList **a_media_list, CRString **a_import_string, CRParsingLocation *a_location)
 Parses an 'import' declaration as defined in the css2 spec in appendix D.1:.
enum CRStatus cr_parser_parse_media (CRParser *a_this)
 Parses a 'media' declaration as specified in the css2 spec at appendix D.1:.
enum CRStatus cr_parser_parse_page (CRParser *a_this)
 Parses '' rule as specified in the css2 spec in appendix D.1: page ::= PAGE_SYM S* IDENT? pseudo_page? S* '{' S* declaration [ ';' S* declaration ]* '}' S*.
enum CRStatus cr_parser_parse_charset (CRParser *a_this, CRString **a_value, CRParsingLocation *a_charset_sym_location)
 Parses a charset declaration as defined implictly by the css2 spec in appendix D.1: charset ::= CHARSET_SYM S* STRING S* ';'.
enum CRStatus cr_parser_parse_font_face (CRParser *a_this)
 Parses the "@font-face" rule specified in the css1 spec in appendix D.1:.
enum CRStatus cr_parser_parse (CRParser *a_this)
 Parses the data that comes from the input previously associated to the current instance of CRParser.
enum CRStatus cr_parser_set_tknzr (CRParser *a_this, CRTknzr *a_tknzr)
enum CRStatus cr_parser_get_tknzr (CRParser *a_this, CRTknzr **a_tknzr)
 Getter of the parser's underlying tokenizer.
enum CRStatus cr_parser_get_parsing_location (CRParser *a_this, CRParsingLocation *a_loc)
 Gets the current parsing location.
enum CRStatus cr_parser_parse_buf (CRParser *a_this, const guchar *a_buf, gulong a_len, enum CREncoding a_enc)
 Parses a stylesheet from a buffer.
void cr_parser_destroy (CRParser *a_this)
 Destroys the current instance of CRParser.


Detailed Description

The definition of the CRParser class.

Definition in file cr-parser.c.


Define Documentation

#define BYTE a_parser,
a_offset,
a_eof   )     cr_tknzr_peek_byte2 (PRIVATE (a_this)->tknzr, a_offset, a_eof)
 

Definition at line 257 of file cr-parser.c.

Referenced by cr_parser_parse_import(), and cr_tknzr_get_next_token().

#define CHARS_TAB_SIZE   12
 

Definition at line 136 of file cr-parser.c.

#define CHECK_PARSING_STATUS status,
is_exception   ) 
 

Value:

if ((status) != CR_OK) \
{ \
        if (is_exception == FALSE) \
        { \
                status = CR_PARSING_ERROR ; \
        } \
        goto error ; \
}
Checks if 'status' equals CR_OK.

If not, goto the 'error' label.

Parameters:
status the status (of type enum CRStatus) to test.
is_exception if set to FALSE, the final status returned by the current function will be CR_PARSING_ERROR. If set to TRUE, the current status will be the current value of the 'status' variable.

Definition at line 153 of file cr-parser.c.

Referenced by cr_parser_parse_expr(), cr_parser_parse_import(), cr_parser_parse_media(), cr_parser_parse_page(), cr_parser_parse_ruleset(), cr_parser_parse_statement_core(), cr_parser_parse_term(), and cr_tknzr_get_next_token().

#define CHECK_PARSING_STATUS_ERR a_this,
a_status,
a_is_exception,
a_err_msg,
a_err_status   ) 
 

Value:

if ((a_status) != CR_OK) \
{ \
        if (a_is_exception == FALSE) a_status = CR_PARSING_ERROR ; \
        cr_parser_push_error (a_this, a_err_msg, a_err_status) ; \
        goto error ; \
}
same as CHECK_PARSING_STATUS() but this one pushes an error on the parser error stack when an error arises.

Parameters:
a_this the current instance of CRParser .
a_status the status to check. Is of type enum CRStatus.
a_is_exception in case of error, if is TRUE, the status is set to CR_PARSING_ERROR before goto error. If is false, the real low level status is kept and will be returned by the upper level function that called this macro. Usally,this must be set to FALSE.

Definition at line 176 of file cr-parser.c.

Referenced by cr_parser_parse_declaration(), and cr_parser_parse_ruleset().

#define ENSURE_PARSING_COND condition   )     if (! (condition)) {status = CR_PARSING_ERROR; goto error ;}
 

Tests the condition and if it is false, sets status to "CR_PARSING_ERROR" and goto the 'error' label.

Parameters:
condition the condition to test.

Definition at line 305 of file cr-parser.c.

Referenced by cr_parser_parse_charset(), cr_parser_parse_font_face(), cr_parser_parse_import(), cr_parser_parse_media(), cr_parser_parse_page(), cr_parser_parse_prio(), cr_parser_parse_statement_core(), and cr_tknzr_get_next_token().

#define ENSURE_PARSING_COND_ERR a_this,
a_condition,
a_err_msg,
a_err_status   ) 
 

Value:

if (! (a_condition)) \
{ \
        status = CR_PARSING_ERROR; \
        cr_parser_push_error (a_this, a_err_msg, a_err_status) ; \
        goto error ; \
}

Definition at line 309 of file cr-parser.c.

Referenced by cr_parser_parse_ruleset().

#define GET_NEXT_TOKEN a_this,
a_token_ptr   ) 
 

Value:

status = cr_tknzr_get_next_token (PRIVATE (a_this)->tknzr, \
                                  a_token_ptr) ; \
ENSURE_PARSING_COND (status == CR_OK) ;

Definition at line 317 of file cr-parser.c.

#define IS_NUM a_char   )     (((a_char) >= '0' && (a_char) <= '9')?TRUE:FALSE)
 

return TRUE if the character is a number ([0-9]), FALSE otherwise

Parameters:
a_char the char to test.

Definition at line 142 of file cr-parser.c.

#define PEEK_BYTE a_parser,
a_offset,
a_byte_ptr   ) 
 

Value:

status = cr_tknzr_peek_byte (PRIVATE (a_this)->tknzr, \
                              a_offset, \
                              a_byte_ptr) ; \
CHECK_PARSING_STATUS (status, TRUE) ;
Peeks a byte from the topmost parser input at a given offset from the current position.

If it fails, goto the "error:" label.

Parameters:
a_parser the current instance of CRParser.
a_offset the offset of the byte to peek, the current byte having the offset '0'.
a_byte_ptr out parameter a pointer (guchar*) to where the peeked char is to be stored.

Definition at line 251 of file cr-parser.c.

#define PEEK_NEXT_CHAR a_this,
a_to_char   ) 
 

Value:

{\
enum CRStatus status ; \
status = cr_tknzr_peek_char  (PRIVATE (a_this)->tknzr, a_to_char) ; \
CHECK_PARSING_STATUS (status, TRUE) \
}
Peeks the next char from the input stream of the current parser by invoking cr_tknzr_input_peek_char().

invokes CHECK_PARSING_STATUS on the status returned by cr_tknzr_peek_char().

Parameters:
a_this the current instance of CRParser.
a_to_char a pointer to the char where to store the char peeked.

Definition at line 194 of file cr-parser.c.

Referenced by cr_parser_parse_font_face(), cr_parser_parse_import(), cr_parser_parse_media(), cr_parser_parse_ruleset(), and cr_tknzr_get_next_token().

#define PRIVATE obj   )     ((obj)->priv)
 

Definition at line 134 of file cr-parser.c.

#define READ_NEXT_BYTE a_this,
a_byte_ptr   ) 
 

Value:

status = cr_tknzr_read_byte (PRIVATE (a_this)->tknzr, a_byte_ptr) ; \
CHECK_PARSING_STATUS (status, TRUE) ;
Reads a byte from the topmost parser input steam.

If it fails, goto the "error" label.

Parameters:
a_this the current instance of CRParser.
a_byte_ptr the guchar * where to put the read char.

Definition at line 267 of file cr-parser.c.

Referenced by cr_parser_parse_expr().

#define READ_NEXT_CHAR a_this,
a_to_char   ) 
 

Value:

status = cr_tknzr_read_char (PRIVATE (a_this)->tknzr, a_to_char) ; \
CHECK_PARSING_STATUS (status, TRUE)
Reads the next char from the input stream of the current parser.

In case of error, jumps to the "error:" label located in the function where this macro is called.

Parameters:
a_this the curent instance of CRParser
to_char a pointer to the guint32 char where to store the character read.

Definition at line 209 of file cr-parser.c.

Referenced by cr_parser_parse_declaration(), cr_parser_parse_font_face(), cr_parser_parse_import(), cr_parser_parse_media(), cr_parser_parse_ruleset(), and cr_tknzr_get_next_token().

#define RECORD_CUR_BYTE_ADDR a_this,
a_addr   ) 
 

Value:

status = cr_tknzr_get_cur_byte_addr \
            (PRIVATE (a_this)->tknzr, a_addr) ; \
CHECK_PARSING_STATUS (status, TRUE)
Gets the address of the current byte inside the parser input.

Parameters:
parser the current instance of CRParser.
addr out parameter a pointer (guchar*) to where the address must be put.

Definition at line 235 of file cr-parser.c.

#define RECORD_INITIAL_POS a_this,
a_pos   ) 
 

Value:

status = cr_tknzr_get_cur_pos (PRIVATE \
(a_this)->tknzr, a_pos) ; \
g_return_val_if_fail (status == CR_OK, status)
Gets information about the current position in the input of the parser.

In case of failure, this macro returns from the calling function and returns a status code of type enum CRStatus.

Parameters:
a_this the current instance of CRParser.
a_pos out parameter. A pointer to the position inside the current parser input. Must

Definition at line 223 of file cr-parser.c.

Referenced by cr_parser_parse_charset(), cr_parser_parse_declaration(), cr_parser_parse_expr(), cr_parser_parse_font_face(), cr_parser_parse_import(), cr_parser_parse_media(), cr_parser_parse_page(), cr_parser_parse_prio(), cr_parser_parse_ruleset(), cr_parser_parse_statement_core(), cr_parser_parse_term(), and cr_tknzr_get_next_token().

#define SKIP_BYTES a_this,
a_nb_bytes   ) 
 

Value:

status = cr_tknzr_seek_index (PRIVATE (a_this)->tknzr, \
                                        CR_SEEK_CUR, a_nb_bytes) ; \
CHECK_PARSING_STATUS (status, TRUE) ;
Skips a given number of byte in the topmost parser input.

Don't update line and column number. In case of error, jumps to the "error:" label of the surrounding function.

Parameters:
a_parser the current instance of CRParser.
a_nb_bytes the number of bytes to skip.

Definition at line 279 of file cr-parser.c.

#define SKIP_CHARS a_parser,
a_nb_chars   ) 
 

Value:

{ \
glong nb_chars = a_nb_chars ; \
status = cr_tknzr_consume_chars \
     (PRIVATE (a_parser)->tknzr,0, &nb_chars) ; \
CHECK_PARSING_STATUS (status, TRUE) ; \
}
Skip utf8 encoded characters.

Updates line and column numbers.

Parameters:
a_parser the current instance of CRParser.
a_nb_chars the number of chars to skip. Must be of type glong.

Definition at line 291 of file cr-parser.c.

Referenced by cr_parser_parse_import(), and cr_tknzr_get_next_token().


Typedef Documentation

typedef struct _CRParserError CRParserError
 

Definition at line 73 of file cr-parser.c.


Enumeration Type Documentation

enum CRParserState
 

Enumeration values:
READY_STATE 
TRY_PARSE_CHARSET_STATE 
CHARSET_PARSED_STATE 
TRY_PARSE_IMPORT_STATE 
IMPORT_PARSED_STATE 
TRY_PARSE_RULESET_STATE 
RULESET_PARSED_STATE 
TRY_PARSE_MEDIA_STATE 
MEDIA_PARSED_STATE 
TRY_PARSE_PAGE_STATE 
PAGE_PARSED_STATE 
TRY_PARSE_FONT_FACE_STATE 
FONT_FACE_PARSED_STATE 

Definition at line 87 of file cr-parser.c.


Function Documentation

void cr_parser_destroy CRParser a_this  ) 
 

Destroys the current instance of CRParser.

Parameters:
a_this the current instance of CRParser to destroy.

Definition at line 4380 of file cr-parser.c.

References cr_doc_handler_unref(), cr_tknzr_unref(), CRParser, and PRIVATE.

Referenced by cr_declaration_parse_from_buf(), cr_declaration_parse_list_from_buf(), cr_om_parser_destroy(), cr_rgb_parse_from_buf(), cr_statement_at_charset_rule_parse_from_buf(), cr_statement_at_import_rule_parse_from_buf(), cr_statement_at_media_rule_parse_from_buf(), cr_statement_at_page_rule_parse_from_buf(), cr_statement_does_buf_parses_against_core(), cr_statement_font_face_rule_parse_from_buf(), cr_statement_ruleset_parse_from_buf(), and cr_term_parse_expression_from_buf().

enum CRStatus cr_parser_get_parsing_location CRParser a_this,
CRParsingLocation a_loc
 

Gets the current parsing location.

Parameters:
a_this the current instance of CRParser
a_loc the parsing location to get.
Returns:
CR_OK upon succesful completion, an error code otherwise.

Definition at line 4331 of file cr-parser.c.

References CR_BAD_PARAM_ERROR, cr_tknzr_get_parsing_location(), CRParser, CRParsingLocation, and PRIVATE.

Referenced by cr_parser_parse_import().

enum CRStatus cr_parser_get_sac_handler CRParser a_this,
CRDocHandler **  a_handler
 

Gets the SAC document handler.

Parameters:
a_this the "this pointer" of the current instance of CRParser.
a_handler out parameter. The returned handler.
Returns:
CR_OK upon successfull completion, an error code otherwise.

Definition at line 2847 of file cr-parser.c.

References CR_BAD_PARAM_ERROR, CRParser, and PRIVATE.

Referenced by cr_om_parser_parse_buf(), and cr_om_parser_parse_file().

enum CRStatus cr_parser_get_tknzr CRParser a_this,
CRTknzr **  a_tknzr
 

Getter of the parser's underlying tokenizer.

Parameters:
a_this the current instance of CRParser
a_tknzr out parameter. The returned tokenizer
Returns:
CR_OK upon succesful completion, an error code otherwise

Definition at line 4314 of file cr-parser.c.

References CR_BAD_PARAM_ERROR, CRParser, and PRIVATE.

Referenced by cr_declaration_parse_list_from_buf().

enum CRStatus cr_parser_get_use_core_grammar CRParser a_this,
gboolean *  a_use_core_grammar
 

Definition at line 2896 of file cr-parser.c.

References CR_BAD_PARAM_ERROR, CRParser, and PRIVATE.

CRParser* cr_parser_new CRTknzr a_tknzr  ) 
 

Creates a new parser to parse data coming the input stream given in parameter.

Parameters:
a_input the input stream of the parser. Note that the newly created parser will ref a_input and unref it when parsing reaches the end of the input stream.
Returns:
the newly created instance of CRParser, or NULL if an error occured.

Definition at line 2731 of file cr-parser.c.

References CR_OK, cr_parser_set_tknzr(), CRParser, CRParserPriv, CRStatus, and PRIVATE.

Referenced by cr_om_parser_parse_buf(), cr_parser_new_from_file(), and cr_parser_new_from_input().

CRParser* cr_parser_new_from_buf guchar *  a_buf,
gulong  a_len,
enum CREncoding  a_enc,
gboolean  a_free_buf
 

Instanciates a new parser from a memory buffer.

Parameters:
a_buf the buffer to parse.
a_len the length of the data in the buffer.
a_enc the encoding of the input buffer a_buf.
a_free_buf if set to TRUE, a_buf will be freed during the destruction of the newly built instance of CRParser. If set to FALSE, it is up to the caller to eventually free it.
Returns:
the newly built parser, or NULL if an error arises.

Definition at line 2761 of file cr-parser.c.

References cr_input_destroy(), cr_input_new_from_buf(), cr_parser_new_from_input(), CRInput, and CRParser.

Referenced by cr_declaration_parse_from_buf(), cr_declaration_parse_list_from_buf(), cr_rgb_parse_from_buf(), cr_selector_parse_from_buf(), cr_statement_at_charset_rule_parse_from_buf(), cr_statement_at_import_rule_parse_from_buf(), cr_statement_at_media_rule_parse_from_buf(), cr_statement_at_page_rule_parse_from_buf(), cr_statement_does_buf_parses_against_core(), cr_statement_font_face_rule_parse_from_buf(), cr_statement_ruleset_parse_from_buf(), and cr_term_parse_expression_from_buf().

CRParser* cr_parser_new_from_file const guchar *  a_file_uri,
enum CREncoding  a_enc
 

Definition at line 2801 of file cr-parser.c.

References cr_parser_new(), cr_tknzr_new_from_uri(), cr_utils_trace_info, CRParser, and CRTknzr.

Referenced by cr_om_parser_parse_file().

CRParser* cr_parser_new_from_input CRInput a_input  ) 
 

Definition at line 2784 of file cr-parser.c.

References cr_parser_new(), cr_tknzr_new(), CRInput, CRParser, and CRTknzr.

Referenced by cr_om_parser_new(), and cr_parser_new_from_buf().

enum CRStatus cr_parser_parse CRParser a_this  ) 
 

Parses the data that comes from the input previously associated to the current instance of CRParser.

Parameters:
a_this the current instance of CRParser.
Returns:
CR_OK ;

Definition at line 4273 of file cr-parser.c.

References CR_BAD_PARAM_ERROR, CRParser, CRStatus, and PRIVATE.

Referenced by cr_parser_parse_buf(), and cr_parser_parse_file().

enum CRStatus cr_parser_parse_buf CRParser a_this,
const guchar *  a_buf,
gulong  a_len,
enum CREncoding  a_enc
 

Parses a stylesheet from a buffer.

Parameters:
a_this the current instance of #CRparser
a_buf the input buffer
a_len the length of the input buffer
a_enc the encoding of the buffer
Returns:
CR_OK upon successful completion, an error code otherwise.

Definition at line 4351 of file cr-parser.c.

References CR_BAD_PARAM_ERROR, CR_ERROR, CR_OK, cr_parser_parse(), cr_parser_set_tknzr(), cr_tknzr_new_from_buf(), CRParser, CRStatus, CRTknzr, and PRIVATE.

Referenced by cr_om_parser_parse_buf().

enum CRStatus cr_parser_parse_charset CRParser a_this,
CRString **  a_value,
CRParsingLocation a_charset_sym_location
 

Parses a charset declaration as defined implictly by the css2 spec in appendix D.1: charset ::= CHARSET_SYM S* STRING S* ';'.

Parameters:
a_this the "this pointer" of the current instance of CRParser.
a_value out parameter. The actual parsed value of the charset declararation. Note that for safety check reasons, *a_value must be set to NULL.
a_charset_sym_location the parsing location of
Returns:
CR_OK upon successfull completion, an error code otherwise.

Definition at line 4032 of file cr-parser.c.

References CHARSET_SYM_TK, CR_BAD_PARAM_ERROR, CR_OK, cr_parser_try_to_skip_spaces_and_comments(), cr_parsing_location_copy(), cr_string_destroy(), cr_tknzr_get_next_token(), cr_tknzr_set_cur_pos(), cr_token_destroy(), CRInputPos, CRParser, CRParsingLocation, CRStatus, CRString, CRToken, ENSURE_PARSING_COND, _CRToken::location, PRIVATE, RECORD_INITIAL_POS, SEMICOLON_TK, _CRToken::str, STRING_TK, and _CRToken::u.

Referenced by cr_statement_at_charset_rule_parse_from_buf().

enum CRStatus cr_parser_parse_declaration CRParser a_this,
CRString **  a_property,
CRTerm **  a_expr,
gboolean *  a_important
 

TODO: return the parsed priority, so that upper layers can take benefit from it.

Parses a "declaration" as defined by the css2 spec in appendix D.1: declaration ::= [property ':' S* expr prio?]?

Parameters:
a_this the "this pointer" of the current instance of CRParser.
a_property the successfully parsed property. The caller *must* free the returned pointer.
a_expr the expression that represents the attribute value. The caller *must* free the returned pointer.
Returns:
CR_OK upon successfull completion, an error code otherwise.

Definition at line 3093 of file cr-parser.c.

References CHECK_PARSING_STATUS_ERR, CR_BAD_PARAM_ERROR, cr_parser_parse_expr(), cr_parser_parse_prio(), cr_parser_try_to_skip_spaces_and_comments(), cr_string_destroy(), cr_term_append_term(), cr_term_destroy(), cr_tknzr_set_cur_pos(), CRInputPos, CRParser, CRStatus, CRString, CRTerm, PRIVATE, READ_NEXT_CHAR, and RECORD_INITIAL_POS.

Referenced by cr_declaration_parse_from_buf(), cr_declaration_parse_list_from_buf(), cr_parser_parse_font_face(), cr_parser_parse_page(), and cr_parser_parse_ruleset().

enum CRStatus cr_parser_parse_expr CRParser a_this,
CRTerm **  a_expr
 

Parses an expression as defined by the css2 spec in appendix D.1: expr: term [ operator term ]*.

Definition at line 2941 of file cr-parser.c.

References CHECK_PARSING_STATUS, CR_BAD_PARAM_ERROR, CR_OK, cr_parser_parse_term(), cr_parser_try_to_skip_spaces_and_comments(), cr_term_append_term(), cr_term_destroy(), cr_tknzr_peek_byte(), cr_tknzr_set_cur_pos(), CRInputPos, CRParser, CRStatus, CRTerm, PRIVATE, READ_NEXT_BYTE, and RECORD_INITIAL_POS.

Referenced by cr_parser_parse_declaration(), and cr_term_parse_expression_from_buf().

enum CRStatus cr_parser_parse_file CRParser a_this,
const guchar *  a_file_uri,
enum CREncoding  a_enc
 

Parses a the given in parameter.

Parameters:
a_this a pointer to the current instance of CRParser.
a_file_uri the uri to the file to load. For the time being, only local files are supported.
Returns:
CR_OK upon successfull completion, an error code otherwise.

Definition at line 2914 of file cr-parser.c.

References CR_BAD_PARAM_ERROR, CR_ERROR, CR_OK, cr_parser_parse(), cr_parser_set_tknzr(), cr_tknzr_new_from_uri(), CRParser, CRStatus, CRTknzr, and PRIVATE.

Referenced by cr_om_parser_parse_file().

enum CRStatus cr_parser_parse_font_face CRParser a_this  ) 
 

Parses the "@font-face" rule specified in the css1 spec in appendix D.1:.

font_face ::= FONT_FACE_SYM S* '{' S* declaration [ ';' S* declaration ]* '}' S*

This function will call SAC handlers whenever it is necessary.

Returns:
CR_OK upon successfull completion, an error code otherwise.

Definition at line 4119 of file cr-parser.c.

References CBO_TK, CR_BAD_PARAM_ERROR, CR_OK, cr_parser_parse_declaration(), cr_parser_try_to_skip_spaces_and_comments(), cr_parsing_location_copy(), cr_string_destroy(), cr_term_destroy(), cr_term_ref(), cr_term_unref(), cr_tknzr_get_next_token(), cr_tknzr_set_cur_pos(), cr_token_destroy(), CRInputPos, CRParser, CRParsingLocation, CRStatus, CRString, CRTerm, CRToken, ENSURE_PARSING_COND, FONT_FACE_SYM_TK, _CRToken::location, PEEK_NEXT_CHAR, PRIVATE, READ_NEXT_CHAR, and RECORD_INITIAL_POS.

Referenced by cr_statement_font_face_rule_parse_from_buf().

enum CRStatus cr_parser_parse_import CRParser a_this,
GList **  a_media_list,
CRString **  a_import_string,
CRParsingLocation a_location
 

Parses an 'import' declaration as defined in the css2 spec in appendix D.1:.

import ::= [STRING|URI] S* [ medium [ ',' S* medium]* ]? ';' S*

Parameters:
a_this the "this pointer" of the current instance of CRParser.
a_medium_list out parameter. A linked list of CRString Each CRString is a string that contains a 'medium' declaration part of the successfully parsed 'import' declaration.
a_import_string out parameter. A string that contains the 'import string". The import string can be either an uri (if it starts with the substring "uri(") or a any other css2 string. Note that *a_import_string must be initially set to NULL or else, this function will return CR_BAD_PARAM_ERROR.
Returns:
CR_OK upon sucessfull completion, an error code otherwise.

Definition at line 3458 of file cr-parser.c.

References BYTE, CHECK_PARSING_STATUS, CR_BAD_PARAM_ERROR, CR_OK, cr_parser_get_parsing_location(), cr_parser_try_to_skip_spaces_and_comments(), cr_string_destroy(), cr_tknzr_peek_char(), cr_tknzr_set_cur_pos(), CRInputPos, CRParser, CRParsingLocation, CRStatus, CRString, ENSURE_PARSING_COND, PEEK_NEXT_CHAR, PRIVATE, READ_NEXT_CHAR, RECORD_INITIAL_POS, and SKIP_CHARS.

Referenced by cr_statement_at_import_rule_parse_from_buf().

enum CRStatus cr_parser_parse_media CRParser a_this  ) 
 

Parses a 'media' declaration as specified in the css2 spec at appendix D.1:.

media ::= S* medium [ ',' S* medium ]* '{' S* ruleset* '}' S*

Note that this function calls the required sac handlers during the parsing to notify media productions. See CRDocHandler to know the callback called during parsing.

Parameters:
a_this the "this pointer" of the current instance of CRParser.
Returns:
CR_OK upon successfull completion, an error code otherwise.

Definition at line 3616 of file cr-parser.c.

References CHECK_PARSING_STATUS, CR_BAD_PARAM_ERROR, CR_OK, cr_parser_parse_ruleset(), cr_parser_try_to_skip_spaces_and_comments(), cr_parsing_location_copy(), cr_string_destroy(), cr_tknzr_get_next_token(), cr_tknzr_set_cur_pos(), cr_token_destroy(), CRInputPos, CRParser, CRParsingLocation, CRStatus, CRString, CRToken, ENSURE_PARSING_COND, IDENT_TK, _CRToken::location, MEDIA_SYM_TK, PEEK_NEXT_CHAR, PRIVATE, READ_NEXT_CHAR, RECORD_INITIAL_POS, _CRToken::str, and _CRToken::u.

Referenced by cr_statement_at_media_rule_parse_from_buf().

enum CRStatus cr_parser_parse_page CRParser a_this  ) 
 

Parses '' rule as specified in the css2 spec in appendix D.1: page ::= PAGE_SYM S* IDENT? pseudo_page? S* '{' S* declaration [ ';' S* declaration ]* '}' S*.

This function also calls the relevant SAC handlers whenever it encounters a construction that must be reported to the calling application.

Parameters:
a_this the "this pointer" of the current instance of CRParser.
Returns:
CR_OK upon successfull completion, an error code otherwise.

Definition at line 3783 of file cr-parser.c.

References CBC_TK, CBO_TK, CHECK_PARSING_STATUS, CR_BAD_PARAM_ERROR, CR_OK, cr_parser_parse_declaration(), cr_parser_try_to_skip_spaces_and_comments(), cr_parsing_location_copy(), cr_string_destroy(), cr_term_destroy(), cr_term_ref(), cr_term_unref(), cr_tknzr_get_next_token(), cr_tknzr_set_cur_pos(), cr_tknzr_unget_token(), cr_token_destroy(), CRInputPos, CRParser, CRParsingLocation, CRStatus, CRString, CRTerm, CRToken, DELIM_TK, ENSURE_PARSING_COND, _CRToken::location, PAGE_SYM_TK, PRIVATE, and RECORD_INITIAL_POS.

Referenced by cr_statement_at_page_rule_parse_from_buf().

enum CRStatus cr_parser_parse_prio CRParser a_this,
CRString **  a_prio
 

Parses a declaration priority as defined by the css2 grammar in appendix C: prio: IMPORTANT_SYM S*.

Parameters:
a_this the current instance of CRParser.
a_prio a string representing the priority. Today, only "!important" is returned as only this priority is defined by css2.

Definition at line 3044 of file cr-parser.c.

References CR_BAD_PARAM_ERROR, CR_OK, cr_parser_try_to_skip_spaces_and_comments(), cr_string_new_from_string(), cr_tknzr_get_next_token(), cr_tknzr_set_cur_pos(), cr_token_destroy(), CRInputPos, CRParser, CRStatus, CRString, CRToken, ENSURE_PARSING_COND, IMPORTANT_SYM_TK, PRIVATE, and RECORD_INITIAL_POS.

Referenced by cr_parser_parse_declaration().

enum CRStatus cr_parser_parse_ruleset CRParser a_this  ) 
 

Parses a "ruleset" as defined in the css2 spec at appendix D.1.

ruleset ::= selector [ ',' S* selector ]* '{' S* declaration? [ ';' S* declaration? ]* '}' S*;

This methods calls the the SAC handler on the relevant SAC handler callbacks whenever it encounters some specific constructions. See the documentation of CRDocHandler (the SAC handler) to know when which SAC handler is called.

Parameters:
a_this the "this pointer" of the current instance of CRParser.
Returns:
CR_OK upon successfull completion, an error code otherwise.

Definition at line 3245 of file cr-parser.c.

References CHECK_PARSING_STATUS, CHECK_PARSING_STATUS_ERR, CR_BAD_PARAM_ERROR, CR_OK, cr_parser_parse_declaration(), cr_parser_try_to_skip_spaces_and_comments(), cr_selector_ref(), cr_selector_unref(), cr_simple_sel_destroy(), cr_string_destroy(), cr_term_ref(), cr_term_unref(), cr_tknzr_peek_char(), cr_tknzr_set_cur_pos(), CRInputPos, CRParser, CRSelector, CRSimpleSel, CRStatus, CRString, CRTerm, ENSURE_PARSING_COND_ERR, PEEK_NEXT_CHAR, PRIVATE, READ_NEXT_CHAR, and RECORD_INITIAL_POS.

Referenced by cr_parser_parse_media(), and cr_statement_ruleset_parse_from_buf().

enum CRStatus cr_parser_parse_statement_core CRParser a_this  ) 
 

Parses a statement as defined by the css core grammar in chapter 4.1 of the css2 spec.

statement : ruleset | at-rule;

Parameters:
a_this the current instance of CRParser.
Returns:
CR_OK upon successfull completion, an error code otherwise.

Definition at line 3184 of file cr-parser.c.

References ATKEYWORD_TK, CHARSET_SYM_TK, CHECK_PARSING_STATUS, CR_BAD_PARAM_ERROR, CR_OK, cr_tknzr_get_next_token(), cr_tknzr_set_cur_pos(), cr_tknzr_unget_token(), cr_token_destroy(), CRInputPos, CRParser, CRStatus, CRToken, ENSURE_PARSING_COND, FONT_FACE_SYM_TK, IMPORT_SYM_TK, MEDIA_SYM_TK, PAGE_SYM_TK, PRIVATE, and RECORD_INITIAL_POS.

Referenced by cr_statement_does_buf_parses_against_core().

enum CRStatus cr_parser_parse_term CRParser a_this,
CRTerm **  a_term
 

Parses a "term" as defined in the css2 spec, appendix D.1: term ::= unary_operator? [NUMBER S* | PERCENTAGE S* | LENGTH S* | EMS S* | EXS S* | ANGLE S* | TIME S* | FREQ S* | function ] | STRING S* | IDENT S* | URI S* | RGB S* | UNICODERANGE S* | hexcolor.

TODO: handle parsing of 'RGB'

Parameters:
a_term out parameter. The successfully parsed term.
Returns:
CR_OK upon successfull completion, an error code otherwise.

Definition at line 1499 of file cr-parser.c.

References ANGLE_TK, CHECK_PARSING_STATUS, CR_BAD_PARAM_ERROR, CR_OK, cr_parser_try_to_skip_spaces_and_comments(), cr_parsing_location_copy(), cr_string_destroy(), cr_term_append_term(), cr_term_destroy(), cr_term_new(), cr_term_set_function(), cr_term_set_hash(), cr_term_set_ident(), cr_term_set_number(), cr_term_set_rgb(), cr_term_set_string(), cr_term_set_uri(), cr_tknzr_get_next_token(), cr_tknzr_set_cur_pos(), cr_tknzr_unget_token(), cr_token_destroy(), CRInputPos, CRParser, CRParsingLocation, CRStatus, CRString, CRTerm, CRToken, DELIM_TK, EMS_TK, EXS_TK, FREQ_TK, LENGTH_TK, _CRToken::location, _CRTerm::location, _CRToken::num, PERCENTAGE_TK, PRIVATE, RECORD_INITIAL_POS, _CRToken::rgb, _CRToken::str, TIME_TK, _CRToken::u, and _CRToken::unichar.

Referenced by cr_parser_parse_expr(), and cr_rgb_parse_from_buf().

enum CRStatus cr_parser_set_default_sac_handler CRParser a_this  ) 
 

Sets the SAC handler associated to the current instance of CRParser to the default SAC handler.

Parameters:
a_this a pointer to the current instance of CRParser.
Returns:
CR_OK upon successfull completion, an error code otherwise.

Definition at line 2863 of file cr-parser.c.

References CR_BAD_PARAM_ERROR, cr_doc_handler_destroy(), cr_doc_handler_new(), cr_doc_handler_set_default_sac_handler(), cr_parser_set_sac_handler(), CRDocHandler, CRParser, CRStatus, and PRIVATE.

enum CRStatus cr_parser_set_sac_handler CRParser a_this,
CRDocHandler a_handler
 

Sets a SAC document handler to the parser.

Parameters:
a_this the "this pointer" of the current instance of CRParser.
a_handler the handler to set.
Returns:
CR_OK upon successfull completion, an error code otherwise.

Definition at line 2824 of file cr-parser.c.

References CR_BAD_PARAM_ERROR, cr_doc_handler_ref(), cr_doc_handler_unref(), CRParser, and PRIVATE.

Referenced by cr_parser_set_default_sac_handler(), cr_statement_at_media_rule_parse_from_buf(), cr_statement_at_page_rule_parse_from_buf(), cr_statement_font_face_rule_parse_from_buf(), and cr_statement_ruleset_parse_from_buf().

enum CRStatus cr_parser_set_tknzr CRParser a_this,
CRTknzr a_tknzr
 

Definition at line 4290 of file cr-parser.c.

References CR_BAD_PARAM_ERROR, cr_tknzr_ref(), cr_tknzr_unref(), CRParser, and PRIVATE.

Referenced by cr_parser_new(), cr_parser_parse_buf(), and cr_parser_parse_file().

enum CRStatus cr_parser_set_use_core_grammar CRParser a_this,
gboolean  a_use_core_grammar
 

Definition at line 2885 of file cr-parser.c.

References CR_BAD_PARAM_ERROR, CRParser, and PRIVATE.

Referenced by cr_statement_does_buf_parses_against_core().

enum CRStatus cr_parser_try_to_skip_spaces_and_comments CRParser a_this  ) 
 

Same as cr_parser_try_to_skip_spaces() but this one skips spaces and comments.

Parameters:
a_this the current instance of CRParser.
Returns:
CR_OK upon successfull completion, an error code otherwise.

Definition at line 615 of file cr-parser.c.

References COMMENT_TK, CR_BAD_PARAM_ERROR, cr_tknzr_get_next_token(), cr_tknzr_unget_token(), cr_token_destroy(), CRParser, CRStatus, CRToken, and PRIVATE.

Referenced by cr_declaration_parse_from_buf(), cr_declaration_parse_list_from_buf(), cr_parser_parse_charset(), cr_parser_parse_declaration(), cr_parser_parse_expr(), cr_parser_parse_font_face(), cr_parser_parse_import(), cr_parser_parse_media(), cr_parser_parse_page(), cr_parser_parse_prio(), cr_parser_parse_ruleset(), cr_parser_parse_term(), cr_rgb_parse_from_buf(), cr_statement_at_charset_rule_parse_from_buf(), cr_statement_at_import_rule_parse_from_buf(), cr_statement_at_media_rule_parse_from_buf(), cr_statement_at_page_rule_parse_from_buf(), cr_statement_font_face_rule_parse_from_buf(), cr_statement_ruleset_parse_from_buf(), and cr_term_parse_expression_from_buf().


Generated on Fri Oct 29 08:29:13 2004 for Libcroco by  doxygen 1.3.9.1