Boost logo

Boost-Commit :

From: hartmut.kaiser_at_[hidden]
Date: 2008-02-14 18:54:11


Author: hkaiser
Date: 2008-02-14 18:54:10 EST (Thu, 14 Feb 2008)
New Revision: 43265
URL: http://svn.boost.org/trac/boost/changeset/43265

Log:
Wave: More fixes to whitespace insertion engine.
Text files modified:
   branches/release/boost/wave/util/insert_whitespace_detection.hpp | 59 +++++++++++++++++++++++++++++++++++----
   1 files changed, 52 insertions(+), 7 deletions(-)

Modified: branches/release/boost/wave/util/insert_whitespace_detection.hpp
==============================================================================
--- branches/release/boost/wave/util/insert_whitespace_detection.hpp (original)
+++ branches/release/boost/wave/util/insert_whitespace_detection.hpp 2008-02-14 18:54:10 EST (Thu, 14 Feb 2008)
@@ -260,6 +260,8 @@
                 return false; // no insertion between parens/brackets/braces
 
             default:
+ if (IS_CATEGORY(prev, OperatorTokenType))
+ return false;
                 break;
             }
             break;
@@ -281,6 +283,8 @@
             case T_QUESTION_MARK:
                 if (T_QUESTION_MARK == beforeprev)
                     return true;
+ if (IS_CATEGORY(prev, OperatorTokenType))
+ return false;
                 break;
                 
             default:
@@ -290,6 +294,8 @@
                             
         case T_MINUS:
         case T_MINUSMINUS:
+ case T_PLUS:
+ case T_PLUSPLUS:
         case T_LESS:
         case T_EQUAL:
         case T_ASSIGN:
@@ -300,8 +306,27 @@
         case T_NOTEQUAL:
         case T_DIVIDEASSIGN:
         case T_MINUSASSIGN:
- if (T_QUESTION_MARK == prev && T_QUESTION_MARK == beforeprev)
- return true; // ??{op}
+ switch (static_cast<unsigned int>(prev)) {
+ case T_LEFTPAREN:
+ case T_RIGHTPAREN:
+ case T_LEFTBRACKET:
+ case T_RIGHTBRACKET:
+ case T_LEFTBRACE:
+ case T_RIGHTBRACE:
+ case T_SEMICOLON:
+ case T_COMMA:
+ case T_COLON:
+ // no insertion between parens/brackets/braces and operators
+ return false;
+
+ case T_QUESTION_MARK:
+ if (T_QUESTION_MARK == beforeprev)
+ return true;
+ break;
+
+ default:
+ break;
+ }
             break;
 
         case T_COMPL_ALT:
@@ -313,9 +338,30 @@
         case T_ORASSIGN_ALT:
         case T_XORASSIGN_ALT:
         case T_NOTEQUAL_ALT:
- if (T_IDENTIFIER == prev || T_NONREPLACABLE_IDENTIFIER == prev ||
- IS_CATEGORY(prev, KeywordTokenType))
- return true;
+ switch (static_cast<unsigned int>(prev)) {
+ case T_LEFTPAREN:
+ case T_RIGHTPAREN:
+ case T_LEFTBRACKET:
+ case T_RIGHTBRACKET:
+ case T_LEFTBRACE:
+ case T_RIGHTBRACE:
+ case T_SEMICOLON:
+ case T_COMMA:
+ case T_COLON:
+ // no insertion between parens/brackets/braces and operators
+ return false;
+
+ case T_IDENTIFIER:
+ if (T_NONREPLACABLE_IDENTIFIER == prev ||
+ IS_CATEGORY(prev, KeywordTokenType))
+ {
+ return true;
+ }
+ break;
+
+ default:
+ break;
+ }
             break;
             
         case T_STAR:
@@ -325,8 +371,7 @@
         }
 
     // else, handle operators separately
- if (T_COMMA != current && T_COMMA != prev &&
- IS_CATEGORY(current, OperatorTokenType) &&
+ if (IS_CATEGORY(current, OperatorTokenType) &&
             IS_CATEGORY(prev, OperatorTokenType))
         {
             return true; // operators must be delimited always


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk