⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cpptest.cpp

📁 这是一个很不错的词法语法分析器! 很适合计算机专业的大学生学习参考
💻 CPP
字号:
// CppTest.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "CppLex.h"
#include "CppDyer.h"
#include <sstream>
#include <fstream>
#include <iostream>

using namespace std;
using namespace CppParser;

class HtmlEncoder
{
	int mPositionInLine;
	bool mIsInFontTag;
	string mLastColor;
public:
	HtmlEncoder()
	{
		cout<<"<FONT FACE=\"Fixedsys\">";
		mPositionInLine=0;
		mIsInFontTag=false;
	}
	string encode(const string& s,const std::string& color)
	{
		std::string r;
		if(mLastColor!=color)
		{
			mLastColor=color;
			if(mIsInFontTag)
			{
				r+="</FONT><FONT COLOR=\"";
				r+=color;
				r+="\">";
			}
			else
			{
				r+="<FONT COLOR=\"";
				r+=color;
				r+="\">";
			}
		}
		for(std::string::size_type i=0;i<s.size();++i)
		{
			if(s[i]=='\"')
				r+="&quot;";
			else if(s[i]=='&')
				r+="&amp;";
			else if(s[i]=='<')
				r+="&lt;";
			else if(s[i]=='>')
				r+="&gt;";
			else if(s[i]==' ')
				r+="&nbsp;";
			else if(s[i]=='\t')
			{
				for(int i=0;i<4-mPositionInLine%4;++i)
					r+="&nbsp;";
				mPositionInLine+=4-mPositionInLine%4;
				continue;
			}
			else if(s[i]=='\n')
			{
				r+="<br>";
				mPositionInLine=0;
				continue;
			}
			else
				r+=s[i];
			++mPositionInLine;
		}
		return r;
	}
	string flush()
	{
		if(mIsInFontTag)
			return "</FONT>";
		cout<<"</FONT>";
	}
};

int main(int argc, char* argv[])
{
	cerr<<"CppDyer 0.99  (c) by PolyRandom, all right reserved"<<endl;
	cerr<<"This version is for debug only, please check"<<endl;
	cerr<<"http://www.polyrandom.com/"<<endl;
	cerr<<"for bug report and latest versions"<<endl;
	cerr<<endl;
	if(argc!=3)
	{
		cerr<<"USAGE: CppDyer <ini file name> <cpp file name>"<<endl;
		return 0;
	}
	cerr<<"Converting..."<<endl;
	try
	{
		CppDyer cd(argv[1]);
		cd.processFile(argv[2]);
		cerr<<"done"<<endl;
	}
	catch(...)
	{
		cerr<<"failed"<<endl;
	}
	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -