53 using namespace parameter_substitution;
62 static string quote(
string const & str)
66 if (ch ==
'\\' || ch ==
'\"') {
78 _value(ref.invocation())
95 case handling::substitute_arg:
98 case handling::substitute_quoted_arg: {
100 auto quoted_arg =
quote(
args().at(param_i));
101 args()[param_i] = quoted_arg;
104 case handling::substitute_expanded_arg:
127 size_t len = size_t(chew) - off;
131 chew = off + e.
id().size();
142 for ( ;start <
args().
size(); ++start) {
157 size_t mark = size_t(chew);
159 if (
size_t(chew) > mark) {
160 s += format.substr(mark,
size_t(chew) - mark);
165 size_t next_size = s.size() +
args().
at(param_i).size();
169 <<
"\" not done. Will exceed max expansion size "
187 unique_ptr<expansion_base>
192 return unique_ptr<expansion_base>(peb);
struct unexplained_expansion encapsulates macro-expansion of a reference where the --explain option i...
unsigned edit_buf(std::string &str, expansion_base const &e, size_t off=0)
Replace all remaining occurrences of a reference throughout a string.
std::string const & at(size_t n) const
Get a range-checked [const] reference to the nth parameter.
virtual std::string const & invocation() const
Get a string representation of the reference.
std::string str() const
Cast the parameter list to its canonical string representation.
void set_expansion_flags()
Assign the expand-flags of the reference's arguments, if any, in accordance with the definition...
argument_list const & args() const
Get a [const] reference to the argument_list of the reference.
expansion_base(reference const &ref)
Construct from a reference.
size_t size() const
Get the number of parameters in the parameter_list_base
unsigned edit_trailing_args(expansion_base const &e, size_t start=0)
Replace all occurrences of a reference throughout a terminal segment of this expansions's arguments...
symbol::locator const & callee() const
Get a [const] the state of the referenced symbol.
warning_msg< 35 > warning_incomplete_expansion
Report a macro reference not fully expanded.
Class argument_list encapsulates a list of macro arguments, i.e. the arguments to a macro reference...
size_t find_first_in(std::string const &id, chewer< CharSeq > &chew)
Find the first occurrence of an identifier within a terminal segment a CharSeq
struct explained_expansion encapsulates macro-expansion of a reference when the --explain option is o...
bool is_expandable(size_t n) const
Say whether the nth argument, if any, is eligible for macro expansion.
std::string read(chewer< CharSeq > &chew)
Read an identifier from an chewer<CharSeq>
std::string const & id() const
Get the name of the symbol referenced.
bool substitute()
Substitute the fully expanded arguments into the definition of the reference, returning true if the c...
The tag class is inserted in a diagnostic_base to tell it to emit itself.
handling get_handling() const
Get the handling of the specified parameter.
void sync()
Synchronise the object with the associated sequence_type
static std::unique_ptr< expansion_base > factory(bool explain, reference const &ref)
Global factory of subclasses of expansion_base
void edit(std::string &str, size_t at, size_t len, std::string const &replacement)
struct paramater_substitution::specifier encapsulates a parameter substitution specifier.
unsigned short get_param_index() const
Get the index of the specified parameter.
std::shared_ptr< parameter_substitution::format const > format() const
Get a pointer to the symbol's substitution format; null if none.
static constexpr unsigned max_expansion_size()
Cut-off size for macro-expansions.
`template struct chewer<CharSeq> is a cursor-like type that is associated with a character-sequence t...
std::string _value
The current expanded value.
std::string const & value() const
Get the current expanded value of the reference.
struct expansion_base is an abstract base for classes that encapsulate a mode of macro-expansion of a...
bool set_expandable(size_t n, bool expandable=false)
Set the nth expand-flag to indicate whether the nth argument, if any, is eligible for macro expansion...
static string quote(string const &str)
Return the quotation of a string.
chew_mode::literal_space const literal_space
An exemplar chew_mode::literal_space