Click here to Skip to main content
15,894,539 members
Articles / Programming Languages / C++

Useful Managers

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
11 Aug 2001 80.6K   1.2K   16  
An add-in for Devstudio that provides tag indexing and search, window, bookmarks, session and other managers
#include <clex.h>

/* #line 1 "D:\UsefulManagers_src\Parser\lexer.l" */

/****************************************************************************
lexer.l
****************************************************************************/

#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <assert.h>
#include "parser.h"


// repeated because of possible precompiled header
#include <clex.h>

#include "lexer.h"

/////////////////////////////////////////////////////////////////////////////
// constructor

YYLEXNAME::YYLEXNAME()
{
	yytables();
/* #line 50 "D:\UsefulManagers_src\Parser\lexer.l" */

  assert(false);

}

#ifndef YYTEXT_SIZE
#define YYTEXT_SIZE 100
#endif
#ifndef YYUNPUT_SIZE
#define YYUNPUT_SIZE YYTEXT_SIZE
#endif

// backwards compatability with lex
#ifdef input
int YYLEXNAME::yyinput()
{
	return input();
}
#else
#define input yyinput
#endif

#ifdef output
void YYLEXNAME::yyoutput(int ch)
{
	output(ch);
}
#else
#define output yyoutput
#endif

#ifdef unput
void YYLEXNAME::yyunput(int ch)
{
	unput(ch);
}
#else
#define unput yyunput
#endif

#ifndef YYNBORLANDWARN
#ifdef __BORLANDC__
#pragma warn -rch		// <warning: unreachable code> off
#endif
#endif

int YYLEXNAME::yyaction(int action)
{
/* #line 64 "D:\UsefulManagers_src\Parser\lexer.l" */

// extract yylval for use later on in actions
YYSTYPE& yylval = *(YYSTYPE*)yyparserptr->yylvalptr;

	yyreturnflg = 1;
	switch (action) {
	case 1:
		{
/* #line 71 "D:\UsefulManagers_src\Parser\lexer.l" */
 return SOURCE; 
		}
		break;
	case 2:
		{
/* #line 76 "D:\UsefulManagers_src\Parser\lexer.l" */
 return '=';    
		}
		break;
	case 3:
		{
/* #line 77 "D:\UsefulManagers_src\Parser\lexer.l" */
 return INCL;
		}
		break;
	case 4:
		{
/* #line 80 "D:\UsefulManagers_src\Parser\lexer.l" */
 /* do nothing*/
		}
		break;
	case 5:
		{
/* #line 81 "D:\UsefulManagers_src\Parser\lexer.l" */
 return '\n'; 
		}
		break;
	case 6:
		{
/* #line 83 "D:\UsefulManagers_src\Parser\lexer.l" */
 yylval.string = phrase(); return PHRASE1; 
		}
		break;
	case 7:
		{
/* #line 84 "D:\UsefulManagers_src\Parser\lexer.l" */
 yylval.string = id(); return STRING; 
		}
		break;
	case 8:
		{
/* #line 86 "D:\UsefulManagers_src\Parser\lexer.l" */
 
		}
		break;
	default:
		yyassert(0);
		break;
	}
	yyreturnflg = 0;
	return 0;
}

#ifndef YYNBORLANDWARN
#ifdef __BORLANDC__
#pragma warn .rch		// <warning: unreachable code> to the old state
#endif
#endif
/* #line 88 "D:\UsefulManagers_src\Parser\lexer.l" */


/////////////////////////////////////////////////////////////////////////////
// Lexer commands

Lexer::Lexer(const char* str)
{
  yytables();
  openFile(str);
}

Lexer::~Lexer()
{
  for(int i=0;i<strings.size();i++)
    delete strings[i];
}

/////////////////////////////////////////////////////////////////////////////
// Lexer attribute commands
void Lexer::openFile(const char* str)
{
  FILE* file = fopen(str,"r");
  if(file)
    m_files.push_back(file);
}
void Lexer::closeFile()
{
  if(m_files.size())
  {
    fclose(*m_files.rbegin());
    m_files.erase(m_files.end()-1);
  }
}

string* Lexer::phrase()
{
  string* s = id();
  assert(*s->begin()=='\"');
  assert(*(s->end()-1)=='\"');
  s->erase(s->end()-1);
  s->erase(s->begin());
  return s;
}

string* Lexer::id()
{
  string* p = new string(yytext);
  strings.push_back(p);
  return p;
}


//#define TRACE_AUTOMAT_PARSER 

int Lexer::yygetchar()
{
  if(!m_files.size())
    return EOF;
  int c = getc(*m_files.rbegin());
#ifdef TRACE_AUTOMAT_PARSER
  char str[2];
  str[0] = c;
  str[1] = 0;
  OutputDebugString(str);
#endif
  switch(c)
  {
    case EOF:
      closeFile(); // retrun \n
    case '\n' :
    case '\r' :
    case ';'  :
     return '\n';
  }
  return c;
}


void YYLEXNAME::yytables()
{
	yystext_size = YYTEXT_SIZE;
	yysunput_size = YYUNPUT_SIZE;

	static const yymatch_t YYNEARFAR YYBASED_CODE match[] = {
		0
	};
	yymatch = match;

	yytransitionmax = 315;
	static const yytransition_t YYNEARFAR YYBASED_CODE transition[] = {
		{ 0, 0 },
		{ 0, 0 },
		{ 0, 0 },
		{ 0, 0 },
		{ 0, 0 },
		{ 0, 0 },
		{ 0, 0 },
		{ 0, 0 },
		{ 0, 0 },
		{ 0, 0 },
		{ 6, 1 },
		{ 7, 1 },
		{ 0, 0 },
		{ 0, 0 },
		{ 0, 0 },
		{ 0, 0 },
		{ 0, 0 },
		{ 0, 0 },
		{ 0, 0 },
		{ 0, 0 },
		{ 0, 0 },
		{ 0, 0 },
		{ 0, 0 },
		{ 0, 0 },
		{ 0, 0 },
		{ 0, 0 },
		{ 0, 0 },
		{ 0, 0 },
		{ 0, 0 },
		{ 0, 0 },
		{ 0, 0 },
		{ 0, 0 },
		{ 0, 0 },
		{ 6, 1 },
		{ 9, 1 },
		{ 8, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 16, 12 },
		{ 9, 1 },
		{ 9, 1 },
		{ 16, 16 },
		{ 0, 0 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 5, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 0, 0 },
		{ 0, 0 },
		{ 4, 1 },
		{ 0, 0 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 3, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 15, 11 },
		{ 9, 1 },
		{ 12, 5 },
		{ 9, 1 },
		{ 9, 1 },
		{ 11, 3 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 9, 1 },
		{ 17, 15 },
		{ 18, 17 },
		{ 19, 18 },
		{ 9, 1 },
		{ 13, 13 },
		{ 13, 13 },
		{ 14, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 0, 0 },
		{ 13, 13 },
		{ 13, 13 },
		{ 0, 0 },
		{ 0, 0 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 0, 0 },
		{ 0, 0 },
		{ 0, 0 },
		{ 0, 0 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 0, 0 },
		{ 13, 13 },
		{ 0, 0 },
		{ 13, 13 },
		{ 13, 13 },
		{ 0, 0 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 13, 13 },
		{ 0, 0 },
		{ 0, 0 },
		{ 9, 19 },
		{ 13, 13 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 0, 0 },
		{ 9, 19 },
		{ 9, 19 },
		{ 0, 0 },
		{ 0, 0 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 0, 0 },
		{ 0, 0 },
		{ 0, 0 },
		{ 0, 0 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 0, 0 },
		{ 9, 19 },
		{ 0, 0 },
		{ 9, 19 },
		{ 9, 19 },
		{ 0, 0 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 9, 19 },
		{ 0, 0 },
		{ 0, 0 },
		{ 0, 0 },
		{ 9, 19 }
	};
	yytransition = transition;

	static const yystate_t YYNEARFAR YYBASED_CODE state[] = {
		{ 0, 0, 0 },
		{ -10, 1, 0 },
		{ 1, 0, 0 },
		{ 19, 18, 7 },
		{ 0, 0, 2 },
		{ 19, 21, 7 },
		{ 0, 0, 4 },
		{ 0, 0, 5 },
		{ 13, 0, 8 },
		{ 19, 0, 7 },
		{ 0, 0, 8 },
		{ 19, 7, 7 },
		{ 19, 8, 3 },
		{ 19, 96, 0 },
		{ 0, 0, 6 },
		{ 19, 42, 7 },
		{ 0, 11, 3 },
		{ 19, 58, 7 },
		{ 19, 57, 7 },
		{ 0, 188, 1 }
	};
	yystate = state;

	static const yybackup_t YYNEARFAR YYBASED_CODE backup[] = {
		0,
		0,
		0,
		0,
		0,
		0,
		0,
		0,
		0
	};
	yybackup = backup;
}

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Russian Federation Russian Federation
Mike has been programming in C/C++ for 11 years and Visual C++/MFC for 4 years. His background includes pure and applied mathematics, engineering and physics, and he is currently based in Moscow, Russia.

Comments and Discussions