coan 4.2.4
|
![]() |
typedef struct eval_result const* symbol_const_h |
typedef struct eval_result* symbol_h |
bool is_symbol_inner_char | ( | char | cp | ) |
Say whether can occur within a symbol, except possibly in the first position.
Definition at line 587 of file symbol.c.
Referenced by chew_header_name(), chew_symbol(), configured_symbol_find(), delete_paren(), is_valid_symbol_char(), and symbol_is_legal().
bool is_symbol_start_char | ( | char | cp | ) |
Say whether a character can be the first character of a symbol.
Definition at line 581 of file symbol.c.
Referenced by chew_symbol(), eval_hash_include(), eval_unary(), is_valid_symbol_char(), match_keyword(), and symbol_is_legal().
void symbol_assign | ( | symbol_h | dest, |
symbol_const_h | src | ||
) |
Assign one symbol to another.
dest | The symbol to be assigned |
src | The symbol to be assigned to dest. |
Definition at line 310 of file symbol.c.
References symbol_copy(), symbol_dispose(), and symbol_swap().
int symbol_compare | ( | symbol_const_h | lhs, |
void const * | rhs, | ||
size_t | namelen | ||
) |
Compare a symbol with another symbol or a name.
lhs | First symbol to be compared. |
rhs | Second symbol or name to compare. |
namelen | If 0 then rhs addresses a second symbol to be compared by name with lhs. Otherwise rhs addresses a name of length namelen to be compared with the name of lhs. |
Definition at line 540 of file symbol.c.
References symbol_name_compare().
Referenced by symbol_equal().
symbol_h symbol_copy | ( | symbol_const_h | src | ) |
Construct a copy of a symbol.
src | The symbol to copy |
Definition at line 288 of file symbol.c.
References symbol_copy_init(), and zallocate().
Referenced by symbol_assign().
line_type_t symbol_define | ( | symbol_h | sym, |
char const * | tail, | ||
char const ** | pend | ||
) |
Assign a definition to a symbol.
sym | The symbol to be defined. |
tail | Pointer to text immediately following the parsed symbol name. |
pend | NULL, or a pointer at which the address of first unconsumed character beginning from tail will be stored on return. |
Definition at line 334 of file symbol.c.
References canonical_string_dispose(), canonical_string_equal(), canonical_string_new(), flush_contradiction(), forget_contradiction(), GET_PUBLIC, GRIPE_DIFFERING_REDEF, GRIPE_DUPLICATE_ARGS, GRIPE_GARBAGE_ARG, GRIPE_GLOBAL_FUNCTION_LIKE_MACRO_DEFINITION, GRIPE_INSOURCE_FUNCTION_LIKE_MACRO_DEFINITION, GRIPE_INVALID_ARGS, GRIPE_TRANSIENT_SYMBOL_ADDED, insert_contradiction(), INSOURCE, is_unconditional_line(), eval_result::line, LT_DIRECTIVE_DROP, LT_DIRECTIVE_KEEP, eval_result::most_resolved, report_symbol_configuration(), SET_GLOBAL_SYM, SET_INSOURCE_SYM, eval_result::sym_def, symbol_definition(), symbol_is_configured(), and symbol_is_global().
Referenced by configured_symbol_add().
canonical_string_const_h symbol_definition | ( | symbol_const_h | sym | ) |
Get the definition of a symbol.
sym | The symbol whose definition is to be queried. |
Definition at line 533 of file symbol.c.
Referenced by configured_symbol_match_const(), eval_line(), eval_possible_symbol(), eval_unary(), symbol_define(), symbol_definition_resolve(), symbol_equal(), symbol_resolve(), and symbol_undefine().
void symbol_dispose | ( | symbol_h | sym | ) |
Dispose of a symbol object, releasing its resources. If sym is NULL the call is a no-op.
Definition at line 279 of file symbol.c.
References eval_result_clear().
Referenced by symbol_assign(), and symbol_evaluate_status().
bool symbol_equal | ( | symbol_const_h | lhs, |
symbol_const_h | rhs | ||
) |
Say whether two symbols are equal.
lhs | The first symbol to compare. |
rhs | The second symbol to compare. |
Definition at line 320 of file symbol.c.
References canonical_string_equal(), eq(), symbol_compare(), and symbol_definition().
line_type_t symbol_evaluate_status | ( | bool | define, |
char const * | symstart, | ||
const char * | tail, | ||
const char ** | pend | ||
) |
Evaluate the defined/undefined status of a symbol by parsing a commandline option or in-source directive.
This function processes all contexts in which a symbol may be defined or undefined, whether commandline -D or -U options or in-source #define or #undef directives. In the latter case the function makes no presumption that the directive is an active one. If the directive is active, the symbol will be configured appropriately as defined or defined. If it is not, no change of symbol status will be made.
The functions performs all reporting with respect to the parsed symbol that is required by the operative options.
define | Is this symbol configured as defined, or undefined? |
symstart | Pointer to the start of a symbol name. |
tail | Either NULL a pointer to the text following the parsed occurrence of the symbol name. If not NULL then symstart is assumed to address just the symbol name null-terminated. Otherwise the symbol name is parsed from symstart. |
pend | Ignored if tail is NULL. Otherwise, if pend is not NULL, it is a pointer at which the address of the first unconsumed character beginning from tail will be stored on return. |
If tail is NULL then symstart is assumed to be the start of a commandline argument to a -D or -U option. Otherwise tail is assumed to address the text following the parsed symbol name is a #define or #undef directive.
Definition at line 667 of file symbol.c.
References chew_symbol(), CMD_SYMBOLS, configured_symbol_add(), configured_symbol_match(), dropping_line(), eligible_line(), HASH_DEFINE, HASH_UNDEF, INSOURCE, LT_DIRECTIVE_KEEP, report_symbol(), symbol_dispose(), symbol_is_configured(), and symbol_new().
Referenced by eval_hash_define(), eval_hash_undef(), and parse_command_args().
bool symbol_is_configured | ( | symbol_const_h | sym | ) |
Say whether a symbol is configured, either globally or in-source /param sym The name of the symbol to query. /return True if a symbol named symname is configured, else false.
Definition at line 567 of file symbol.c.
References GLOBAL_SYM, and INSOURCE_SYM.
Referenced by configured_symbol_add(), configured_symbol_match_const(), symbol_define(), symbol_evaluate_status(), symbol_resolve(), and symbol_undefine().
bool symbol_is_global | ( | symbol_const_h | sym | ) |
Say whether a symbol is configured globally, i.e. by a -D or -U commandline option, rather than in-source by a #define or #undef directive. /param sym The name of the symbol to query. /return True if a symbol named symname is configured globally, else false.
Definition at line 574 of file symbol.c.
References GLOBAL_SYM.
Referenced by symbol_define(), and symbol_undefine().
bool symbol_is_legal | ( | char const * | tok, |
size_t | toklen | ||
) |
Say whether a token is legal preprocesor symbol name.
tok | Start of the token. |
toklen | Length of the token |
Definition at line 553 of file symbol.c.
References is_symbol_inner_char(), and is_symbol_start_char().
char const* symbol_name | ( | symbol_const_h | sym | ) |
Get the name of a symbol.
sym | The symbol whose name is to be queried. |
Definition at line 526 of file symbol.c.
Referenced by configured_symbol_find(), configured_symbol_match_const(), eval_possible_symbol(), report_symbol(), report_symbol_configuration(), symbol_definition_resolve(), symbol_name_compare(), and symbol_resolve().
symbol_h symbol_new | ( | char const * | name, |
size_t | namelen | ||
) |
Construct a new symbol object
name | Pointer to the name of the symbol. |
namelen | The length of the symbol name. |
Definition at line 268 of file symbol.c.
References symbol_init(), and zallocate().
Referenced by hash_include_new(), symbol_evaluate_status(), and unconfigured_symbol_tally().
bool symbol_reported | ( | symbol_const_h | sym | ) |
Say whether a symbol has been reported.
Definition at line 593 of file symbol.c.
References REPORTED.
Referenced by report_symbol().
canonical_string_const_h symbol_resolve | ( | symbol_h | sym, |
ptr_vector_h | history | ||
) |
Get the most resolved value of a symbol reference.
sym | The symbol whose most resolved value is wanted. |
history | Either NULL or else ptr_vector_h containing the the configured symbols that have been passed as the first parameter to recursively ancestral calls to the function. If sym is already in this list then one or more circular definitions exist. |
If the symbol is neither defined nor undefined, its most resolved form is NULL.
If the symbol is undefined, its most resolved form is the string "0".
If the symbol is defined then its definition is recursively resolved by substitution of the definitions of defined symbol references. In the string that results from this exhaustive resolution, each maximally long portion that is soluble CPP expression is evaluated and replaced with its integer value. The result of this final replacement is the most resolved form of the symbol reference.
In case a symbol is found to have a circular definition, its most resolved form is taken to be the symbol name.
The function stores the most resolved form of the symbol reference internally in the symbol and returns that copy as const.
Definition at line 600 of file symbol.c.
References canonical_numeral(), canonical_string_dispose(), canonical_string_new(), canonical_string_text(), clone(), eval_definition_text(), eval_result_clear(), eval_result_set_value(), GRIPE_CIRCULAR_SYM_DEF, eval_result::most_resolved, ptr_vector_append(), ptr_vector_begin_const(), ptr_vector_drop(), ptr_vector_end_const(), ptr_vector_new(), report(), RESOLVED, SET_KEEP, symbol_definition(), symbol_definition_resolve(), symbol_is_configured(), symbol_name(), and eval_result::value.
Referenced by eval_possible_symbol(), report_symbol(), and symbol_definition_resolve().
Exchange two symbols
Definition at line 298 of file symbol.c.
References canonical_string_swap(), eval_result::flags, eval_result::most_resolved, PODSWAP, eval_result::sym_def, eval_result::sym_name, and eval_result::value.
Referenced by symbol_assign().
line_type_t symbol_undefine | ( | symbol_h | sym, |
char const * | tail, | ||
char const ** | pend | ||
) |
Remove any definition from a symbol.
sym | The symbol to be undefined. |
tail | Pointer to text immediately following the parsed symbol name. |
pend | NULL, or a pointer at which the address of first unconsumed character beginning from tail will be stored on return. |
Definition at line 449 of file symbol.c.
References canonical_string_dispose(), eval_result_set_value(), flush_contradiction(), GET_PUBLIC, GRIPE_DUPLICATE_ARGS, GRIPE_GARBAGE_ARG, GRIPE_INVALID_ARGS, GRIPE_TRANSIENT_SYMBOL_ADDED, GRIPE_UNDEFING_DEFINED, INSOURCE, int_spec_false, is_unconditional_line(), eval_result::line, LT_DIRECTIVE_DROP, LT_DIRECTIVE_KEEP, eval_result::most_resolved, report_symbol_configuration(), save_contradiction(), SET_GLOBAL_SYM, SET_INSOURCE_SYM, SET_PUBLIC, eval_result::sym_def, symbol_definition(), symbol_is_configured(), and symbol_is_global().
Referenced by configured_symbol_add().