85 explicit locator(symbol_table::iterator iter)
89 explicit locator(std::string
const &
id);
109 template<
class CharSeq>
126 explicit operator bool()
const {
143 return &
_loc->second;
146 return &
_loc->second;
151 std::string
const &
id()
const {
163 return id() == other.
id();
172 std::string
const &
id()
const {
194 std::shared_ptr<std::string const>
defn()
const {
208 std::shared_ptr<parameter_substitution::format const>
format()
const {
354 std::string
const & definition);
397 symbol_table::iterator result =
table().find(
id);
398 return result ==
table().end() ?
419 template<
class CharSeq>
525 static bool selected(std::string
const &
id);
530 static bool deselected(std::string
const &
id);
563 static symbol_table::iterator
565 std::string
const &
id,
567 symbol_table::iterator hint =
table().end()) {
570 where->second._provenance = source;
571 where->second._loc =
locator(where);
603 std::shared_ptr<parameter_substitution::format>
_format;
632 : _loc(
symbol::table().begin()) {}
641 template<
class CharSeq>
symbol * operator->()
Point.
locator _loc
Locator of this symbol in the symbol table.
static int _last_global_snapshot_
The last snapshot number consumed by the global configuration.
std::string signature() const
Get the symbol's reference signature as string.
void undef()
Undefine thesymbol.
std::string str() const
Cast the parameter list to its canonical string representation.
void clear_parameters()
Remove any macro parameter list.
void subscribe_to(locator other)
Record the symbol's definition as referring to another another symbol, and recursively as referring t...
static bool add_pattern(std::string const &pattern)
Add a symbol name pattern for reporting.
locator(symbol_table::iterator iter)
Construct from a symbol table iterator.
static bool selected(std::string const &id)
Say whether a symbol name matches a selection pattern for reporting.
The symbol is globally configured by a commandline option.
std::shared_ptr< std::string const > defn() const
Get a pointer to the symbol's definition; null if undefined.
bool invoked() const
Say whether the symbol has been invoked.
locator(std::string const &id, provenance source)
Construct given a name and a provenance.
struct symbol::locator encapsulates a symbol table entry.
bool in_progress() const
Say whether a determination the symbol's state is in progress.
bool null() const
Say whether this locator is null.
static locator find_any_in(chewer< CharSeq > &chew, size_t &off)
Search a terminal portion of a CharSeq for any known symbol name.
symbol & operator*()
Defeference.
symbol(provenance source)
Explicitly construct given a provenance.
bool operator!=(symbol const &other) const
Inequality.
void make_clean()
Assign the symbol state the current sequential snapshot number, signifying that it is up-to-date...
std::string const & id() const
Get the name of the symbol.
void set_definition(std::string const &defn)
Set the definition of the symbol.
void set_pseudo_snapshot(pseudo_snapshot n=pseudo_snapshot::pristine)
Prime the symbol with a pseudo snapshot.
bool configured() const
Say whether the symbol is configured.
static bool wildcard_match(std::string const &wildcard, std::string const &name)
Say whether a symbol name matches a *-terminated wildcard prefix.
static symbol_table _sym_tab_
The symbol table.
The symbol is not configured.
line_type digest_transient_define(formal_parameter_list const ¶ms, std::string const &definition)
Analyse and handle an in-source define directive for this symbol.
formal_parameter_list _params
List of the symbol's macro arguments, if any.
static size_t count()
Get the number of symbols in the symbol table.
static void set_selection(char const *optarg)
void define(std::string const &defn, formal_parameter_list const ¶ms)
Define symbol.
std::vector< symbol::locator > _contributors
static locator lookup(std::string const &id)
Lookup an identifier in the symbol table.
std::string const & id() const
Get the name of the symbol.
unsigned _line
Source line-number where symbol last defined or undefined, or 0.
bool variadic() const
Say whether this symbol is a variadic macro.
void set_invoked(bool value=true)
Mark the symbol as invoked, or not.
void make_dirty(pseudo_snapshot n=pseudo_snapshot::pristine)
Assign the symbol state a pseudo snapshot number, signifying that it is out of date, and recursively to all its subscribers.
std::vector< bool > _no_expand_pararms
static void report_global_config()
Report the global configuration, according to options.
static symbol_table & table()
Get a reference to the symbol table.
std::shared_ptr< parameter_substitution::format > _format
line_type digest_transient_undef()
Analyse and handle an in-source undef directive for this symbol.
provenance
Symbolic constants denoting the provenance of a symbol.
formal_parameter_list const & parameters() const
Get the symbol's formal parameter list.
std::string read(chewer< CharSeq > &chew)
Read an identifier from an chewer<CharSeq>
bool defined() const
Is the symbol defined.
bool operator==(symbol const &other) const
Equality.
static symbol_table::iterator insert(std::string const &id, provenance source, symbol_table::iterator hint=table().end())
Insert the symbol into the symbol table with a specified provenance.
void report() const
Report a reference to this symbol.
Symbol is in the process of being undefined.
chew_mode::name const name
An exemplar chew_mode::name
static int _current_snapshot_
The current sequential snapshot number.
void report_premiere()
Report a symbol as resolved from the global configuration. The method invokes itself recursively on a...
provenance origin() const
Get the provenance of the symbol.
void diagnose_retrospective_redefinition() const
Diagnose the case in which defining or undefining the symbol retrospectively changes the expansion of...
bool subscribes_to(locator other) const
Say whether the symbol's definition refers to another another symbol, directly or indirectly...
static void per_file_init()
Delete all transient symbols from the symbol table.
static std::set< std::string > _selected_symbols_set_
The set of symbols selected for reporting, if any.
void subscribe()
Acquire all the symbol's contributors.
std::shared_ptr< parameter_substitution::format const > format() const
Get a pointer to the symbol's substitution format; null if none.
bool operator==(locator other) const
Equality.
The symbol is transiently configured by an in-source directive.
std::shared_ptr< std::string > _defn
Pointer to the symbol's definition, if any.
symbol_table::value_type table_entry
Type of entry in the symbol table.
void set_parameters(formal_parameter_list const ¶ms)
Set a macro parameter list for the symbol.
`template struct chewer<CharSeq> is a cursor-like type that is associated with a character-sequence t...
provenance _provenance
The provenance of the symbol.
void digest_global_define(chewer< std::string > &chew)
Analyse and handle a -D option for this symbol.
bool dirty() const
Say whether cached references of this symbol are out of date, due to configuration changes of this sy...
bool _deselected
Is the symbol deselected?
References of the symbol are by definition insoluble.
pseudo_snapshot
Pseudo snapshot numbers for symbols in indeterminate states.
std::map< std::string, symbol > symbol_table
Type of map implementing the symbol tbale.
static table_entry _null_
The table entry of the null symbol.
bool deselected() const
Say whether the symbol is deselected per the --select option.
friend reference
Friendship to struct reference
Symbol is in the process of being defined.
void set_parameters(size_t n)
Impute n parameters of the symbol.
bool variadic() const
Say whether the parameter_list_base is variadic.
line_type
Enumeration of types of input lines.
std::vector< symbol::locator > _subscribers
List of locators of the symbols to which this one contributes.
Symbol has merely be constructed.
struct symbol encapsulates a preprocessor symbol's state
bool operator!=(locator &other) const
Inequality.
void make_self_referential()
Assign the symbol state a pseudo snapshot number, signifying that its definition involves an infinite...
size_t which_parameter(std::string const &str) const
Say whether a string is a parameter of the symbol.
void originate(provenance origin)
Set the symbol's provenance.
symbol_table::iterator _loc
Locator of the symbol in the symbol table.
size_t which(std::string const &str) const
Get the index of the parameter that matches a string, if any, else -1.
bool self_referential() const
Say whether the symbol's definition is infinitely regressive.
bool clean() const
Say whether the symbol's state has been determined.
char * optarg
Argument to an option parsed by getopt_long()
locator()
The default constructor locates the null symbol.
void unsubscribe()
Forget all the symbol's contributors.
void digest_global_undef(chewer< std::string > &chew)
Analyse and handle a -U option for this symbol.
bool _invoked
Has the symbol been invoked?
unsigned line() const
Get the source line-number at which this symbol was last defined or undefined.
int snapshot_max() const
Get the maximum sequential snapshot number in the the recursive closure of this symbol its contributo...