110 map<string, directive_type>
128 auto where = _keyword_to_type_map_.find(keyword);
129 if (where == _keyword_to_type_map_.end()) {
131 << keyword <<
emit();
134 return where->second;
138 std::string
const & arg)
144 std::cout <<
'#' << keyword <<
' ' << arg;
153 std::string
const & keyword,
154 std::string
const & arg)
172 if (sloc->configured()) {
173 if (sloc->defined()) {
196 line_type retval = _evaluator_tab_[type](chew);
202 string good = pretty.substr(0,
size_t(chew));
203 string bad = pretty.substr(
size_t(chew));
205 "Superfluous \"" << bad <<
"\" after directive \""
206 << good <<
'\"' <<
emit();
253 size_t mark = size_t(chew);
256 size_t(chew) == mark + 1 && (i.
raw() == 1 || i.
raw() == 0)) {
269 if (ep.is_simplified() && lineval ==
LT_IF) {
279 return eval_ifdef_or_ifndef(_type_,chew);
285 return eval_ifdef_or_ifndef(_type_,chew);
320 macro_params.
read(chew);
323 <<
"Malformed macro parameter for symbol \""
324 << sloc.id() <<
"\"" <<
emit();
331 string arg = sloc.id();
332 if (definition.length()) {
339 retval = sloc->digest_transient_define(macro_params,definition);
355 retval = sloc->digest_transient_undef();
376 <<
"#include expects <FILENAME> or \"FILENAME\""
379 shared_ptr<reference> ref = hi.symbolic_argument();
409 "An operative #error directive was input"
413 "An operative #error directive was output" <<
emit();
424 size_t off = size_t(chew);
435 "#line expects a line-number" <<
emit();
static parsed_line & cur_line()
Get a reference to the current output line.
bool well_formed() const
Say whether the parameter_list_base is well-formed.
static bool implicit()
Do we implicitly --undef all unconfigured symbols?
warning_msg< 32 > warning_no_argument
Report a directive that lacks a required argument.
static bool list_only_once()
Do we report only the first occurrence of listed items?
static void forget()
Forget about an apparent contradiction.
unsigned long long raw() const
Get the bits comprising the integer as an unsigned long long
void set_directive_type(directive_type dtype)
Set the directive type of the line.
static integer read_numeral(chewer< CharSeq > &chew)
Read a numeral from a chewer<CharSeq>
A directive line of no more specific type that is to be kept.
static bool eval_wip()
Do we evaluate constants in truth-functional contexts or treat them as unknowns.
warning_msg< 17 > warning_invalid_include
Report a problematic argument to an #include directive.
error_msg< 17 > error_malformed_macro
Report a malformed macro parameter list.
static void report(std::string const &keyword, std::string const &arg)
Report a directive.
#define TOK_IFNDEF
Constant denoting the #ifndef directive.
static std::map< std::string, directive_type > _keyword_to_type_map_
Map from keywords to directive types.
integer const & value() const
Get the integral value of the expression.
struct hash_include encapsulates an #include directive.
struct symbol::locator encapsulates a symbol table entry.
bool dropping() const
Are we dropping the line?
warning_msg< 16 > warning_unknown_directive
Report an unknown preprocessor directive.
Encapsulates a directive of a given type.
static bool was_unconditional_line()
Is the current line outside any #if scope?
static command_code get_command()
Get the operative coan command code.
static bool is_unconditional_line()
Is the current line outside any #if scope or in the scope of a satisfied #if?
Encapsulates parsing of preprocessor expressions.
static line_type eval_ifdef_or_ifndef(directive_type type, chewer< parse_buffer > &chew)
Evaluate an #ifdef or #ifndef directive.
#define TOK_INCLUDE
Constant denoting the #include directive.
warning_msg< 10 > warning_garbage_after_directive
Report garbage text was input following a directive.
#define TOK_ELSE
Constant denoting the #else directive.
error_msg< 15 > error_if_without_cond
Report #if or #elif has no argument.
#define TOK_PRAGMA
Constant denoting the #pragma directive.
void replace(std::string const &replacement)
Replace the line with another string.
static line_type eval(std::string keyword, chewer< parse_buffer > &chew)
Evaluate a directive.
#define TOK_ELIF
Constant denoting the #elif directive.
Class integer encapsulates an integer of some type.
static std::string in_file_name()
Get the name of the current source file.
struct warning_unconditional_error_output encapsulates a diagnostic for an error directive output unc...
static line_type eval(chewer< parse_buffer > &chew)
Evaluate a directive of this type.
unsigned num() const
Get the greatest source line number spanned by this line.
#define TOK_IFDEF
Constant denoting the #ifdef directive.
directive_type
Symbolic constants denoting types of directives.
static directive_type get_type(std::string const &keyword)
Get the directive_type of a directive given a keyword.
#define TOK_ERROR
Constant denoting the #error directive.
A directive line of no more specific type than that is to be dropped.
chew_mode::continuation const continuation
An exemplar chew_mode::continuation
The tag class is inserted in a diagnostic_base to tell it to emit itself.
An #else that we can't resolve.
#define TOK_DEFINE
Constant denoting the #define directive.
chew_mode::greyspace const greyspace
An exemplar chew_mode::greyspace
#define TOK_ENDIF
Constant denoting the #endif directive.
bool resolved() const
Say whether the expression has been resolved.
static bool list_location()
Do we report file and line numbers for listed items?
static void flush()
Discharge any pending contradiction.
integer_type type() const
Get the type of the integer
bool reportable()
Is the line reportable for the operative command.
static std::vector< evaluator > _evaluator_tab_
Table of evaluation functions for directive types, indexed by directive_type.
warning_msg< 33 > warning_not_a_line_number
Report a #line directive with argument not a positive integer.
`template struct chewer<CharSeq> is a cursor-like type that is associated with a character-sequence t...
#define TOK_LINE
Constant denoting the line directive.
template class canonical<What> encapsulates the canonical representation of values of type What...
void set_simplified(bool value=true)
Classifiy the line as simplified or not.
static size_t discard(unsigned reason)
Discard any queued diagnostics that match a reason-code, returning the number discarded.
line_type
Enumeration of types of input lines.
static void erase_all()
Forget all directives table used by the operative command.
An #elif that we can't resolve.
static std::string pretty()
Get a pretty printable version of the current input line.
bool is_true() const
Say whether the expression is true.
#define TOK_IF
Constant denoting the if directive.
struct evaluation represents the result of evaluating a putative expression.
An #if that we can't resolve.
#define TOK_UNDEF
Constant denoting the #undef directive.