stif/Parser/src/StifParser.cpp
branchRCL_3
changeset 13 da2cedce4920
parent 0 a03f92240627
child 18 3406c99bc375
equal deleted inserted replaced
12:d27dfa8884ad 13:da2cedce4920
   843 //
   843 //
   844 //    Class: CStifParser
   844 //    Class: CStifParser
   845 //
   845 //
   846 //    Method: HandleSpecialMarks
   846 //    Method: HandleSpecialMarks
   847 //
   847 //
   848 //    Description: Handles special marks.( '\/\/', '\/\*' and '*/\/' ). This
   848 //    Description: Handles special marks.( '\/' and '\*' ). This
   849 //         		   is used when ECStyleComments comment type is used.
   849 //         		   is used when ECStyleComments comment type is used.
   850 //
   850 //
   851 //    Parameters: TPtr& aBuf: inout: section to parsed
   851 //    Parameters: TPtr& aBuf: inout: section to parsed
   852 //
   852 //
   853 //    Return Values: None
   853 //    Return Values: None
   860 //
   860 //
   861 void CStifParser::HandleSpecialMarks( TPtr& aBuf )
   861 void CStifParser::HandleSpecialMarks( TPtr& aBuf )
   862     {
   862     {
   863     TLex lex( aBuf );
   863     TLex lex( aBuf );
   864     TInt firstPos( 0 );
   864     TInt firstPos( 0 );
   865     TInt secondPos( 0 );
   865     
   866 
   866     //        Replace \/ with /
   867     //        // => \/\/ => //
   867     //        Replace \* with *
   868     //        /* => \/\* => /*
   868     
   869     //        */ => \*\/ => */
       
   870   
       
   871     do
   869     do
   872         {
   870         {
       
   871         //RDebug::Print( _L("Print : %S"), &aBuf );
   873         firstPos = lex.Offset();
   872         firstPos = lex.Offset();
   874         TChar get = lex.Get();
   873         TChar get = lex.Get();
   875         // Check is '\'
   874         // Check is '\'
   876         if( get == '\\' ) 
   875         if( get == '\\' ) 
   877             {
   876             {
   878             // Peek next character( '/' )
   877             firstPos = (lex.Offset()-1);
   879             if( lex.Peek() == '/' )
   878             // Peek next character( '/' or '*' )
   880                 {
   879             if( lex.Peek() == '/' || lex.Peek() == '*')
   881                 lex.Inc();
   880                 {
   882                 secondPos = lex.Offset();
   881                 aBuf.Delete (firstPos,1);
   883                 // Peek next character( '\' )
   882                 lex = aBuf;
   884                 if( lex.Peek() == '\\' )
       
   885                     {
       
   886                     lex.Inc();
       
   887                     // Peek next character( '/' )
       
   888                     if( lex.Peek() == '/' )
       
   889                         {
       
   890                         // Delete mark '\/\/' and replace this with '//'
       
   891                         aBuf.Delete( secondPos, 1 );
       
   892                         aBuf.Delete( firstPos, 1 );
       
   893                         lex = aBuf;
       
   894                         }
       
   895                     // Peek next character( '/' )
       
   896                     else if( lex.Peek() == '*' )
       
   897                         {
       
   898 						// Delete mark '\/\*' and replace this with '/*'                        
       
   899                         aBuf.Delete( secondPos, 1 );
       
   900                         aBuf.Delete( firstPos, 1 );
       
   901                         lex = aBuf;
       
   902                         }
       
   903                     }
       
   904                 }
       
   905             // Peek next character( '/' )
       
   906             else if( lex.Peek() == '*' )
       
   907                 {
       
   908                 lex.Inc();
       
   909                 secondPos = lex.Offset();
       
   910                 // Peek next character( '\' )
       
   911                 if( lex.Peek() == '\\' )
       
   912                     {
       
   913                     lex.Inc();
       
   914                     // Peek next character( '/' )
       
   915                     if( lex.Peek() == '/' )
       
   916                         {
       
   917                         // Delete mark '\*\/' and replace this with '*\'
       
   918                         aBuf.Delete( secondPos, 1 );
       
   919                         aBuf.Delete( firstPos, 1 );
       
   920                         lex = aBuf;
       
   921                         }
       
   922                     }
       
   923                 }
   883                 }
   924             }
   884             }
       
   885            
   925         firstPos = 0;
   886         firstPos = 0;
   926         secondPos = 0;
       
   927         } while ( !lex.Eos() );
   887         } while ( !lex.Eos() );
   928 
   888 
   929     }
   889     }
   930 
   890 
   931 //  End of File
   891 //  End of File