mirror of
https://github.com/boostorg/wave.git
synced 2026-02-20 03:02:16 +00:00
Added the support_option_insert_whitespace language option.
[SVN r36211]
This commit is contained in:
@@ -83,7 +83,7 @@ class context : private boost::noncopyable
|
||||
public:
|
||||
|
||||
// concept checks
|
||||
// the given iterator shall be at least a forward iterator type
|
||||
// the given iterator should be at least a forward iterator type
|
||||
BOOST_CLASS_REQUIRE(IteratorT, boost, ForwardIteratorConcept);
|
||||
|
||||
// public typedefs
|
||||
@@ -133,6 +133,7 @@ public:
|
||||
#if BOOST_WAVE_EMIT_PRAGMA_DIRECTIVES != 0
|
||||
| support_option_emit_pragma_directives
|
||||
#endif
|
||||
| support_option_insert_whitespace
|
||||
))
|
||||
, hooks(hooks_)
|
||||
{
|
||||
|
||||
@@ -171,7 +171,7 @@ lexer<IteratorT, PositionT>::get()
|
||||
// test identifier characters for validity (throws if invalid chars found)
|
||||
value = string_type((char const *)scanner.tok,
|
||||
scanner.cur-scanner.tok);
|
||||
if (!(language & support_option_no_character_validation))
|
||||
if (!boost::wave::need_no_character_validation(language))
|
||||
impl::validate_identifier_name(value, actline, scanner.column, filename);
|
||||
break;
|
||||
|
||||
@@ -180,9 +180,9 @@ lexer<IteratorT, PositionT>::get()
|
||||
// test literal characters for validity (throws if invalid chars found)
|
||||
value = string_type((char const *)scanner.tok,
|
||||
scanner.cur-scanner.tok);
|
||||
if (language & support_option_convert_trigraphs)
|
||||
if (boost::wave::need_convert_trigraphs(language))
|
||||
value = impl::convert_trigraphs(value);
|
||||
if (!(language & support_option_no_character_validation))
|
||||
if (!boost::wave::need_no_character_validation(language))
|
||||
impl::validate_literal(value, actline, scanner.column, filename);
|
||||
break;
|
||||
|
||||
@@ -244,7 +244,7 @@ lexer<IteratorT, PositionT>::get()
|
||||
case T_RIGHTBRACKET_TRIGRAPH:
|
||||
case T_COMPL_TRIGRAPH:
|
||||
case T_POUND_TRIGRAPH:
|
||||
if (language & support_option_convert_trigraphs) {
|
||||
if (boost::wave::need_convert_trigraphs(language)) {
|
||||
value = cache.get_token_value(BASEID_FROM_TOKEN(id));
|
||||
}
|
||||
else {
|
||||
@@ -254,7 +254,7 @@ lexer<IteratorT, PositionT>::get()
|
||||
break;
|
||||
|
||||
case T_ANY_TRIGRAPH:
|
||||
if (language & support_option_convert_trigraphs) {
|
||||
if (boost::wave::need_convert_trigraphs(language)) {
|
||||
value = impl::convert_trigraph(
|
||||
string_type((char const *)scanner.tok));
|
||||
}
|
||||
|
||||
@@ -35,7 +35,8 @@ enum language_support {
|
||||
support_c99 = support_option_variadics | support_option_long_long | 0x08,
|
||||
#endif
|
||||
|
||||
support_option_mask = 0xFF00,
|
||||
support_option_mask = 0xFF80,
|
||||
support_option_insert_whitespace = 0x0080,
|
||||
support_option_preserve_comments = 0x0100,
|
||||
support_option_no_character_validation = 0x0200,
|
||||
support_option_convert_trigraphs = 0x0400,
|
||||
@@ -151,6 +152,7 @@ set_support_options(language_support language, language_support option)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
BOOST_WAVE_OPTION(long_long) // support_option_long_long
|
||||
BOOST_WAVE_OPTION(no_character_validation) // support_option_no_character_validation
|
||||
BOOST_WAVE_OPTION(preserve_comments) // support_option_preserve_comments
|
||||
BOOST_WAVE_OPTION(prefer_pp_numbers) // support_option_prefer_pp_numbers
|
||||
BOOST_WAVE_OPTION(emit_line_directives) // support_option_emit_line_directives
|
||||
@@ -165,6 +167,7 @@ BOOST_WAVE_OPTION(variadics) // support_option_variadics
|
||||
#if BOOST_WAVE_EMIT_PRAGMA_DIRECTIVES != 0
|
||||
BOOST_WAVE_OPTION(emit_pragma_directives) // support_option_emit_pragma_directives
|
||||
#endif
|
||||
BOOST_WAVE_OPTION(insert_whitespace) // support_option_insert_whitespace
|
||||
|
||||
#undef BOOST_WAVE_NEED_OPTION
|
||||
#undef BOOST_WAVE_ENABLE_OPTION
|
||||
|
||||
@@ -262,7 +262,8 @@ public:
|
||||
pos_.get_file().c_str()
|
||||
)),
|
||||
seen_newline(true), must_emit_line_directive(false),
|
||||
act_pos(ctx_.get_main_pos())
|
||||
act_pos(ctx_.get_main_pos()),
|
||||
whitespace(boost::wave::need_insert_whitespace(ctx.get_language()))
|
||||
{
|
||||
act_pos.set_file(pos_.get_file());
|
||||
#if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0
|
||||
@@ -501,6 +502,7 @@ pp_iterator_functor<ContextT>::operator()()
|
||||
}
|
||||
|
||||
// cleanup of certain tokens required
|
||||
seen_newline = false;
|
||||
switch (static_cast<unsigned int>(id)) {
|
||||
case T_NONREPLACABLE_IDENTIFIER:
|
||||
act_token.set_token_id(T_IDENTIFIER);
|
||||
|
||||
@@ -205,13 +205,17 @@ namespace impl {
|
||||
class insert_whitespace_detection
|
||||
{
|
||||
public:
|
||||
insert_whitespace_detection()
|
||||
: prev(boost::wave::T_EOF), beforeprev(boost::wave::T_EOF)
|
||||
insert_whitespace_detection(bool insert_whitespace_ = true)
|
||||
: insert_whitespace(insert_whitespace_),
|
||||
prev(boost::wave::T_EOF), beforeprev(boost::wave::T_EOF)
|
||||
{}
|
||||
|
||||
template <typename StringT>
|
||||
bool must_insert(boost::wave::token_id current, StringT const &value)
|
||||
{
|
||||
if (!insert_whitespace)
|
||||
return false; // skip whitespace insertion alltogether
|
||||
|
||||
using namespace boost::wave;
|
||||
switch (static_cast<unsigned int>(current)) {
|
||||
case T_NONREPLACABLE_IDENTIFIER:
|
||||
@@ -330,11 +334,14 @@ public:
|
||||
}
|
||||
void shift_tokens (boost::wave::token_id next_id)
|
||||
{
|
||||
beforeprev = prev;
|
||||
prev = next_id;
|
||||
if (insert_whitespace) {
|
||||
beforeprev = prev;
|
||||
prev = next_id;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
bool insert_whitespace; // enable this component
|
||||
boost::wave::token_id prev; // the previous analyzed token
|
||||
boost::wave::token_id beforeprev; // the token before the previous
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user