📄 highlight.cpp
字号:
reserved["op"]=reservedinfo(highlight_parameter,OP); reserved["optimize"]=reservedinfo(highlight_parameter,OPTIMIZE); reserved["otherside"]=reservedinfo(highlight_keyword,OTHERSIDE); reserved["periodic"]=reservedinfo(highlight_parameter,PERIODIC); reserved["pi"]=reservedinfo(highlight_global,PI); reserved["plot"]=reservedinfo(highlight_keyword,PLOT); reserved["polar"]=reservedinfo(highlight_keyword,POLAR); reserved["pow"]=reservedinfo(highlight_keyword,POW); reserved["power"]=reservedinfo(highlight_parameter,POWER); reserved["precon"]=reservedinfo(highlight_parameter,PRECON); reserved["problem"]=reservedinfo(highlight_type,PROBLEM); reserved["processor"]=reservedinfo(highlight_keyword,PROCESSOR); reserved["ps"]=reservedinfo(highlight_parameter,PS); reserved["qfe"]=reservedinfo(highlight_parameter,QFE); reserved["qfnbpE"]=reservedinfo(highlight_parameter,QFNBPE); reserved["qfnbpT"]=reservedinfo(highlight_parameter,QFNBPT); reserved["qforder"]=reservedinfo(highlight_parameter,QFORDER); reserved["qft"]=reservedinfo(highlight_parameter,QFT); reserved["ratio"]=reservedinfo(highlight_parameter,RATIO); reserved["readmesh"]=reservedinfo(highlight_keyword,READMESH); reserved["real"]=reservedinfo(highlight_type,REAL); reserved["region"]=reservedinfo(highlight_keyword,REGION); reserved["rescaling"]=reservedinfo(highlight_parameter,RESCALING); reserved["return"]=reservedinfo(highlight_keyword,RETURN); reserved["save"]=reservedinfo(highlight_parameter,SAVE); reserved["savemesh"]=reservedinfo(highlight_keyword,SAVEMESH); reserved["set"]=reservedinfo(highlight_keyword,SET); reserved["sigma"]=reservedinfo(highlight_parameter,SIGMA); reserved["sin"]=reservedinfo(highlight_keyword,SIN); reserved["sinh"]=reservedinfo(highlight_keyword,SINH); reserved["solve"]=reservedinfo(highlight_keyword,SOLVE); reserved["solver"]=reservedinfo(highlight_parameter,SOLVER); reserved["split"]=reservedinfo(highlight_parameter,SPLIT); reserved["splitin2"]=reservedinfo(highlight_parameter,SPLITIN2); reserved["splitmesh"]=reservedinfo(highlight_keyword,SPLITMESH); reserved["splitpbedge"]=reservedinfo(highlight_parameter,SPLITPBEDGE); reserved["sqrt"]=reservedinfo(highlight_keyword,SQRT); reserved["square"]=reservedinfo(highlight_keyword,SQUARE); reserved["strategy"]=reservedinfo(highlight_parameter,STRATEGY); reserved["string"]=reservedinfo(highlight_type,STRING); reserved["sym"]=reservedinfo(highlight_parameter,SYM); reserved["t"]=reservedinfo(highlight_parameter,T); reserved["tan"]=reservedinfo(highlight_keyword,TAN); reserved["tanh"]=reservedinfo(highlight_keyword,TANH); reserved["tgv"]=reservedinfo(highlight_parameter,TGV); reserved["thetamax"]=reservedinfo(highlight_parameter,THETAMAX); reserved["tol"]=reservedinfo(highlight_parameter,TOL); reserved["triangulate"]=reservedinfo(highlight_keyword,TRIANGULATE); reserved["true"]=reservedinfo(highlight_global,FF_TRUE); reserved["trunc"]=reservedinfo(highlight_keyword,TRUNC); reserved["value"]=reservedinfo(highlight_parameter,VALUE); reserved["varf"]=reservedinfo(highlight_type,VARF); reserved["varrow"]=reservedinfo(highlight_parameter,VARROW); reserved["vector"]=reservedinfo(highlight_parameter,VECTOR); reserved["veps"]=reservedinfo(highlight_parameter,VEPS); reserved["verbosity"]=reservedinfo(highlight_global,VERBOSITY); reserved["version"]=reservedinfo(highlight_global,VERSION); reserved["viso"]=reservedinfo(highlight_parameter,VISO); reserved["wait"]=reservedinfo(highlight_parameter,WAIT); // add fh sep 06 reserved["try"]=reservedinfo(highlight_keyword,TRY); reserved["catch"]=reservedinfo(highlight_keyword,CATCH); reserved["throw"]=reservedinfo(highlight_keyword,THROW); reserved["while"]=reservedinfo(highlight_keyword,WHILE); reserved["x"]=reservedinfo(highlight_global,X); reserved["y"]=reservedinfo(highlight_global,Y); reserved["z"]=reservedinfo(highlight_global,Z); // ADD FH oct 2005 reserved["tolpivot"]=reservedinfo(highlight_parameter,TOLPIVOT); reserved["tolpivotsym"]=reservedinfo(highlight_parameter,TOLPIVOTSYM); reserved["l2"]=reservedinfo(highlight_global,L1); reserved["l1"]=reservedinfo(highlight_global,L2); reserved["linfty"]=reservedinfo(highlight_global,LINFTY);// reserved["diag"]=reservedinfo(highlight_global,DIAG); // reserved["coef"]=reservedinfo(highlight_global,COEF); reserved["nbcoef"]=reservedinfo(highlight_global,NBCOEF); // Add set 2006 reserved["im"]=reservedinfo(highlight_global,IM); reserved["re"]=reservedinfo(highlight_global,RE); reserved["eof"]=reservedinfo(highlight_global,FFEOF); reserved["good"]=reservedinfo(highlight_global,GOOD); reserved["scientific"]=reservedinfo(highlight_global,SCIENTIFIC); reserved["fixed"]=reservedinfo(highlight_global,FIXED); reserved["showbase"]=reservedinfo(highlight_global,SHOWBASE); reserved["noshowbase"]=reservedinfo(highlight_global,NOSHOWBASE); reserved["showpos"]=reservedinfo(highlight_global,SHOWPOS); reserved["noshowpos"]=reservedinfo(highlight_global,NOSHOWPOS); reserved["default"]=reservedinfo(highlight_global,DEFAULT); reserved["qf1pE"]=reservedinfo(highlight_keyword,QF1PE); reserved["qf1pElump"]=reservedinfo(highlight_keyword,QF1PELUMP); reserved["qf1pT"]=reservedinfo(highlight_keyword,QF1PT); reserved["qf1pTlump"]=reservedinfo(highlight_keyword,QF1PTLUMP); reserved["qf2pE"]=reservedinfo(highlight_keyword,QF2PE); reserved["qf2pT"]=reservedinfo(highlight_keyword,QF2PT); reserved["qf2pT4P1"]=reservedinfo(highlight_keyword,QF2PT4P1); reserved["qf3pE"]=reservedinfo(highlight_keyword,QF3PE); reserved["qf5pT"]=reservedinfo(highlight_keyword,QF5PT); reserved["qf7pT"]=reservedinfo(highlight_keyword,QF7PT); reserved["qf9pT"]=reservedinfo(highlight_keyword,QF9PT); }int my_yyinput(char *buf,int maxsize){ // Number of characters to read int n=maxsize; if(n>lexinput.size()-lexinputpos) n=lexinput.size()-lexinputpos; // Transfers characters into buf if(n>0){ memcpy(buf,lexinput.data()+lexinputpos,n); lexinputpos+=n; } return n;}bool hl_error=false;void colorize(const YYLTYPE loc,const char color){ if(color==highlight_error) hl_error=true; // Find buffer location from line (always zero) and column int start=loc.first_column; int stop=loc.last_column; assert(stop<=highlight.size()); highlight.replace(start,stop-start,stop-start,color);}// Location of last accepted tokenint currentloc=0;void recordlocation(YYLTYPE *loc,char *text){ loc->first_column=currentloc; currentloc+=strlen(text); loc->last_column=currentloc;}extern int yyparse();extern YYLTYPE yylloc;int my_parse(){ // Initialize highlight string with plain colors highlight=string(lexinput.size(),highlight_plain); // Initializes other static variables lexinputpos=0; currentloc=0; symbols.clear(); words.resize(0); // Run the scan return yyparse();}// FreeFem++ allows any symbol to be defined any number of timesvoid newsymbol(const string n,const string type){ symbols[n]=type;}// Just checks that the name is correctly definedbool definedsymbol(const string n,const string type){ map<string,string>::const_iterator i=symbols.find(n);#ifndef NDEBUG cerr<<"definedsymbol: looking for "<<n<<" as a "<<type<<": "; if(i==symbols.end()) cerr<<"unknown"<<endl; else cerr<<"known as a "<<(*i).second<<endl;#endif return (i!=symbols.end()) && ((*i).second==type);}int nametoken(const string n,YYSTYPE *yylval,const YYLTYPE loc){ // Write this name down, and pass the corresponding index as yylval words.push_back(n); *yylval=words.size()-1; // Determines its dynamic type map<string,string>::const_iterator i=symbols.find(n); if(i==symbols.end()){ // Any FreeFem++ "reserved" word can be hidden by a user-defined // variable. map<string,reservedinfo>::const_iterator j=reserved.find(n); if(j!=reserved.end()){ colorize(loc,(*j).second.color); return (*j).second.lexcode; } else return NAME; } else if((*i).second=="variable") return USER_VARIABLE; else if((*i).second=="type"){ colorize(loc,highlight_type); return USER_TYPE; } else if((*i).second=="problem"){ colorize(loc,highlight_type); return USER_PROBLEM; } else if((*i).second=="function") return USER_FUNCTION; else if((*i).second=="varf"){ colorize(loc,highlight_type); return USER_VARF; } else if((*i).second=="border") return USER_BORDER; else assert(false); return NAME;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -