The theme expression tokenizer

Themes can use a simple expression language to represent the values of things. More...

Data Structures

struct  PosToken
 A token, as output by the tokeniser. More...

Functions

static gboolean parse_number (const char *p, const char **end_return, PosToken *next, GError **err)
 Tokenises a number in an expression.
static gboolean pos_tokenize (const char *expr, PosToken **tokens_p, int *n_tokens_p, GError **err)
 Tokenises an expression.

Detailed Description

Themes can use a simple expression language to represent the values of things.

This is the tokeniser used for that language.

Bug:
We could remove almost all this code by using GScanner instead, but we would also have to find every expression in every existing theme we could and make sure the parse trees were the same.

Function Documentation

static gboolean parse_number ( const char *  p,
const char **  end_return,
PosToken next,
GError **  err 
) [static]

Tokenises a number in an expression.

Parameters:
p a pointer into a string representing an operation; part of an expression somewhere, so not null-terminated
end_return set to a pointer to the end of the number found; but not updated if no number was found at all
next set to either an integer or a float token
[out] err set to the problem if there was a problem
Returns:
TRUE if a valid number was found, FALSE otherwise (and "err" will have been set)
Bug:
The "while (*start)..." part: what's wrong with strchr-ish things?
Bug:
The name is wrong: it doesn't parse anything.

Definition at line 1565 of file theme.c.

References _, PosToken::d, FALSE, META_THEME_ERROR, META_THEME_ERROR_BAD_CHARACTER, META_THEME_ERROR_FAILED, POS_TOKEN_DOUBLE, POS_TOKEN_INT, TRUE, and PosToken::type.

Referenced by pos_tokenize().

static gboolean pos_tokenize ( const char *  expr,
PosToken **  tokens_p,
int *  n_tokens_p,
GError **  err 
) [static]

Tokenises an expression.

Parameters:
expr The expression
[out] tokens_p The resulting tokens
[out] n_tokens_p The number of resulting tokens
[out] err set to the problem if there was a problem
Returns:
True if the expression was successfully tokenised; false otherwise.

Definition at line 1697 of file theme.c.

References _, PosToken::d, FALSE, free_tokens(), IS_VARIABLE_CHAR, META_THEME_ERROR, META_THEME_ERROR_FAILED, NULL, op_from_string(), parse_number(), POS_OP_NONE, POS_TOKEN_CLOSE_PAREN, POS_TOKEN_OPEN_PAREN, POS_TOKEN_OPERATOR, POS_TOKEN_VARIABLE, TRUE, and PosToken::type.

Referenced by meta_draw_spec_new().


Generated on Sat Aug 23 22:04:23 2008 for metacity by  doxygen 1.5.5