Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version
Go to top

Include File Hierarchy Viewer

, 29 Jul 2003
A tool to view the include file hierarchy of your source code.
//====================================================================
// Although great care has gone into developing this software,
// it is provided without any guarantee of reliability, accuracy
// of information, or correctness of operation.  I am not responsible
// for any damages that may occur as a result of using this software.
// Use this software entirely at your own risk.
// Copyright 2003, Chris Richardson
//
// Description: A simple text lexer.
//
//====================================================================

#if !defined(AFX_LEXER_H__141F1594_A9C8_49A1_A9CC_5ABBE15A98BF__INCLUDED_)
#define AFX_LEXER_H__141F1594_A9C8_49A1_A9CC_5ABBE15A98BF__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "Status.h"
#include "Stream.h"

class CToken;

class CLexer  
{
public:
	CLexer();
	virtual ~CLexer();

   ParseStatus             SetStream( CStream * p_poStream );
   virtual ParseStatus     Lex( CToken * p_poToken );
   
   inline const TCHAR *    GetName() const;
   inline unsigned long    GetLinePos() const;
   inline unsigned long    GetLine() const;
   
   // Modes so we can handle <include.h> style strings, and so we won't process escape sequences in them.
   typedef enum
   {
      LEX_MODE_PREPROCESSOR,
      LEX_MODE_PARSER
   }LexMode;

   inline void             SetLexMode( LexMode p_eMode );

protected:
   CStream *               c_poStream;
   unsigned long           c_ulLine;
   unsigned long           c_ulLinePos;
   LexMode                 c_eMode;

   inline void             IncLine();

   ParseStatus             EscapeSequence( CToken * p_poToken, int & p_riCurPos );
   ParseStatus             IntegerSuffix( CToken * p_poToken, TCHAR & p_rcChar );
};

inline const TCHAR * CLexer::GetName() const
{
   return c_poStream ? c_poStream->GetName() : NULL;
}
//
// ------------------------------------------------------------------
//
inline void CLexer::IncLine()
{
   c_ulLine++;
   c_ulLinePos = -1;
};
//
// ------------------------------------------------------------------
//
inline unsigned long CLexer::GetLinePos() const
{
   return c_ulLinePos;
}
//
// ------------------------------------------------------------------
//
inline unsigned long CLexer::GetLine() const
{
   return c_ulLine;
}
//
// ------------------------------------------------------------------
//
inline void CLexer::SetLexMode( LexMode p_eMode )
{
   c_eMode = p_eMode;
}
//
// ------------------------------------------------------------------
//

#endif // !defined(AFX_LEXER_H__141F1594_A9C8_49A1_A9CC_5ABBE15A98BF__INCLUDED_)

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Chris Richardson
Software Developer (Senior)
United States United States
I like to program, I like to sail.

| Advertise | Privacy | Mobile
Web02 | 2.8.140916.1 | Last Updated 30 Jul 2003
Article Copyright 2003 by Chris Richardson
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid