DEV C艹
然后调VsCode
嘤文到天朝文:30分钟
配置文件:调到现在
然后新问题又来了
附加我写的C艹解释器(目前只能拆分语法)
C++explainer.cpp:
#include"function"
using namespace std;
language theLanguage;
int main(int argc,char* argv[]){
theLanguage=getLanguage();
freopen(getFile(theLanguage).data(),"r",stdin);
readMsg=new msg;
cout<<"Reading Files";
readFile();
freopen("explain.txt","w",stdout);
printGrammer();
}
function:
#include<bits/stdc++.h>
#include<math.h>
#include<pthread.h>
#include <windows.h>
using namespace std;
#define SPACE_CHAR ' '
#define ENTER_CHAR '\n'
#define TAB_CHAR 011
#define CLS system("cls")
#define sleep Sleep
#define inRange(l,e,r) (l)<=(e)&&(e)<=(r)
#define MaxExpressionTypeNum 10
#define NEW_LINE printf("\n")
#define pause system("pause")
int playernum;
queue <string> commandQueue;
#define getfnc __FUNCTION__
#define getfile __FILE__
#define getline __LINE__
using namespace std;
typedef string language;
typedef map<language,string> languages;
map<int,language>ACP2Language;
language getLanguage(){
ACP2Language[1200]="English";
ACP2Language[936]="Chinese(Simplfy)";
return ACP2Language[GetACP()];
}
string getFile(language lang){
languages permission;
permission["Chinese(Simplfy)"]="请输入你的C++文件名:";
permission["English"]="Please enter your C++ file name:";
cout<<permission[lang]<<endl;
string fileName;
cin>>fileName;
return fileName;
}
struct msg{
string message;
int dotNum;
float sleepSec;
bool printing;
};
msg *readMsg;
void* printLoadingMSG(void* Msg)
{
msg* printMsg=(msg*)Msg;
int dotNum=0;
CLS;
cout<<(*printMsg).message;
while((*printMsg).printing){
if(dotNum<(*printMsg).dotNum)
{
printf(" .");
dotNum++;
}
else
{
CLS;
cout<<(*printMsg).message;
dotNum=0;
}
sleep((*printMsg).sleepSec*1000);
}
}
int charExpresser(char input)
{
switch(input){
case SPACE_CHAR:
case ';':
case TAB_CHAR:
return 0;
case ENTER_CHAR:
return 11;
case '/':
return 12;
case '*':
return 13;
default:
if(inRange('A',input,'Z')||inRange('a',input,'z')||input=='_'||input=='#')
return 2;
if(inRange('0',input,'9')){
return 3;}
return 1;
}
}
void readFile(){
char tester;
bool started=true;
bool isLastGang=false;
bool onlyNum,lineComment;
string str="";
onlyNum=true;
while(scanf("%c",&tester)!=EOF)
{
assert(charExpresser(tester)!=-1);
switch(charExpresser(tester)){
case 0:
if(started)commandQueue.push(str);
if(started)str="";
isLastGang=false;
onlyNum=true;
break;
case 1:
if(started&&str!="")commandQueue.push(str);
if(started)str="";
if(started)str+=tester;
if(started)commandQueue.push(str);
if(started)str="";
break;
case 2:
onlyNum=false;
case 3:
if(started)str=str+tester;
isLastGang=false;
break;
case 11:
if(!lineComment)
started=true;
isLastGang=false;
break;
if(started)commandQueue.push("\n");
case 12:
if(lineComment&&isLastGang&&(!started))
{started=false;
lineComment=false;
}
isLastGang=true;
break;
case 13:
if(isLastGang&&(!lineComment)){
lineComment=true;
started=false;
}
if(lineComment){
isLastGang=true;
}
}
}
}
void printGrammer(){
CLS;
for(int i=commandQueue.size();i>0;i--)
{
cout<<commandQueue.front();
commandQueue.push(commandQueue.front());
commandQueue.pop();
NEW_LINE;
}
}
然后vs Code读入中文时变成了“�”
而它又支持编辑时输入天朝文?!