Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

Tools/Xabsl2/yabsl/vsyabsl/commentservice.cpp

Go to the documentation of this file.
00001 
00002 /***************************************************************************
00003          Copyright (c) Microsoft Corporation, All rights reserved.             
00004     This code sample is provided "AS IS" without warranty of any kind, 
00005     it is not recommended for use in a production environment.
00006 ***************************************************************************/
00007 
00008 #include "common.h"
00009 #include "languagedef.h"
00010 #include "stdservice.h"
00011 
00012 CommentService::CommentService() : StdService()
00013 {
00014     m_commentNesting    = 0;
00015     m_returnState       = 0;
00016 }
00017 
00018 //---------------------------------------------------------
00019 //  State init/done
00020 //---------------------------------------------------------
00021 
00022 override void CommentService::initColorizerState( inout ColorizerState& cstate )
00023 {
00024     StdService::initColorizerState( cstate );
00025 
00026     m_commentNesting = cstate.load( CommentBits );
00027     m_returnState    = cstate.load( StateBits );
00028 };
00029 
00030 override void CommentService::doneColorizerState( inout ColorizerState& cstate )
00031 {
00032     //this only has effect during a "checkSyntax"
00033     if (m_commentNesting > 0)
00034         lexicalError( SevError, "unexpected end of comment" );
00035 
00036     cstate.save( m_returnState, StateBits );
00037     cstate.save( m_commentNesting, CommentBits );
00038 
00039     StdService::doneColorizerState( cstate );
00040 };
00041 
00042 
00043 //---------------------------------------------------------
00044 //  Comment functionality
00045 //---------------------------------------------------------
00046 final void CommentService::enterComment( in LexState commentState )
00047 {    
00048     if (m_commentNesting == MaxCommentNesting)
00049         lexicalError( SevError, "maximal comment nesting level reached" );
00050     else
00051         m_commentNesting++;
00052 
00053     if (commentState != 0)
00054     {
00055         ASSERT( m_returnState == 0 );
00056         if (m_returnState == 0)
00057             m_returnState = getLexState();
00058         setLexState( commentState );
00059     }
00060 }
00061 
00062 final void CommentService::leaveComment(void)
00063 {
00064     if (m_commentNesting > 0) 
00065         m_commentNesting--;
00066     
00067     if (m_commentNesting == 0)
00068     {
00069         setLexState( m_returnState );
00070         m_returnState = 0;
00071     }
00072 }
00073 
00074 final bool CommentService::inComment(void) const
00075 {
00076     return (m_commentNesting > 0);
00077 }

Generated on Mon Mar 20 22:00:10 2006 for GT2005 by doxygen 1.3.6