本帖最后由 happy886rr 于 2017-5-3 12:31 编辑
COOL解释器基于CLGO,但核心架构完全重写了一次,增加按键支持,改进了变量表识别机制,改进了语法体系,总代码量也突破1800行,跟CLGO语法和运行机制不再一样。此次发布的是COOL解释器1.0版。并附上一个测试:希尔波特催眠术。
百度网盘下载:https://pan.baidu.com/s/1i4ZswEL
图片均为外链

希尔波特催眠术脚本 | @echo off | | mode con cols=100 lines=30 | | cool "%~f0" | | exit | | | | //主函数入口 | | to main | | make :penw=3 | | for :a 5 7 | | ( | | make :penx=500 :peny=-500 | | hilbert_curve 1000/(2^:a-1) :a 90 | | ) | | for :a 6 3 | | ( | | make :penx=500 :peny=-500 | | hilbert_curve 1000/(2^:a-1) :a 90 | | )-1 | | functions_img 1 | | exit | | | | //希尔波特曲线 | | to hilbert_curve :len :recursive_times :angle | | | | if :recursive_times=0 | | ( | | stop | | ) | | | | if :recursive_times/3=1 | | ( | | make :penc=rand(15)+1 | | ) | | | | if or :penc=9 :penc=10 | | ( | | make :penc=7 | | ) | | | | lt :angle | | hilbert_curve :len :recursive_times-1 -:angle | | | | fd :len | | rt :angle | | hilbert_curve :len :recursive_times-1 :angle | | | | fd :len | | hilbert_curve :len :recursive_times-1 :angle | | | | rt :angle | | fd :len | | hilbert_curve :len :recursive_times-1 -:angle | | lt :angle | | | | //旋转体系 | | to functions_img :add | | memuse | | for :a 1 36000 | | ( | | make :penx=0 :peny=0 | | rote :a | | memsee | | ):add | | memoutCOPY |
COOL解释器源码(仅支持gcc编译器): | | | | | | | | | | | #include <cmath> | | #include <stdio.h> | | #include <stdlib.h> | | #include <string.h> | | #include <ctype.h> | | #include <windows.h> | | #include <wincon.h> | | #include <io.h> | | #include <conio.h> | | #include <time.h> | | #include <gdiplus\gdiplus.h> | | | | | | #ifndef Nan__ | | #define Nan__ | | #define NAN log(-1.0) //无效值NAN | | #define isNAN(x) ((x)!=(x)) | | #define NINF log(0.0) //负无穷大 | | #define INF -NINF //无穷大 | | #define PINF -NINF //正无穷大 | | #define isINF(x) (((x)==PINF)||((x)==NINF)) | | #define isPINF(x) ((x)==PINF) | | #define isNINF(x) ((x)==NINF) | | #endif | | | | | | extern "C" HWND WINAPI GetConsoleWindow(); | | | | | | using namespace Gdiplus; | | | | | | | | #define STACK_SIZE 1024 | | | | #define LOOP_LEVELS 64 | | | | #define MAX_WORDS_SIZE 64 | | | | #define KEY_SIZE 23 | | | | #define CYC_SIZE 5 | | | | #define LGC_SIZE 3 | | | | #define GLOBAL_SIZE 18 | | | | | | | | RECT winRECT= {0}; | | LPRECT lrRECT; | | double base_X, base_Y; | | | | HWND hCMD; | | HWND hWND2; | | HWND hWND3; | | | | int CUR_LINENUM; | | | | char* CUR_LINEPOINTER; | | | | HDC hDC; | | HDC hDC1; | | HDC hDC2; | | HDC hDC3; | | | | | | char* tRAM; | | | | char CacheTain[1024]= {0}; | | | | char Auxiliary[1024]= {0}; | | | | BOOL penMODE=TRUE; | | | | BOOL memMODE=FALSE; | | | | | | | | char STACK1[STACK_SIZE]= {0}; | | | | char STACK2[STACK_SIZE]= {0}; | | | | double STACK3[STACK_SIZE]= {0}; | | | | static const char* MATH_WORDS[]= {"TIME", "PI", "SQRT", "LG", "LN", "SIN", "COS", "TAN", "ARCSIN", "ARCCOS", "ARCTAN", "DEG", "ABS", "ROUND", "READ", "CEIL", "EXP", "SINH", "COSH", "TANH", "ARCSINH", "ARCCOSH", "ARCTANH", "RAND", "INT", "FACT", NULL}; | | | | static const char* KEY_WORDS[]= {"FD", "BK", "LT", "RT", "PU", "PD", "PE", "CS", "PR", "HM", "STOP", "EXIT", "FILL", "TEXT", "WAIT", "ROTE", "MEMUSE", "MEMSEE", "MEMOUT", "MAKE", "SETXY", "OVAL", "RECT"}; | | static const char KEY_LLENS[]= { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 4, 4}; | | | | static const char* CYC_WORDS[]= {"IF", "REPEAT", "WHILE", "FOR", "ELIF"}; | | static const char CYC_LLENS[]= { 2, 6, 5, 3, 4}; | | | | static const char* LGC_WORDS[]= {"NOT", "AND", "OR"}; | | static const char LGC_LLENS[]= { 3, 3, 2}; | | | | static const char* GLOBAL_WORDS[]= {":PENX", ":PENY", ":HEADING", ":PENB", ":PENW", ":PENC", ":PENS", ":PENA", ":PEN0", ":PEN1", ":PEN2", ":PEN3", ":PEN4", ":PEN5", ":PEN6", ":PEN7", ":PEN8", ":PEN9"}; | | double GLOBAL_VALUE[]= { 0, 0, 0, 0, 1, 15, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; | | | | | | int Identify_KeyWords(char* Line, int SENSITIVE_NUM, char** WORDS, const char* endstring); | | double RevPolishCore(const char* expression, int PRO_NUM, char** WORDS, double* VALUE); | | | | | | typedef struct | | { | | BYTE R; | | BYTE G; | | BYTE B; | | COLORREF VALUE; | | } STRGB; | | | | STRGB LOGO_RGB[16]= | | { | | { 0, 0, 0,RGB( 0, 0, 0)}, | | { 0, 0,255,RGB( 0, 0,255)}, | | { 0,255, 0,RGB( 0,255, 0)}, | | { 0,255,255,RGB( 0,255,255)}, | | {255, 0, 0,RGB(255, 0, 0)}, | | {238,130,238,RGB(238,130,238)}, | | {165, 42, 42,RGB(165, 42, 42)}, | | {211,211,211,RGB(211,211,211)}, | | {169,169,169,RGB(169,169,169)}, | | {173,216,230,RGB(173,216,230)}, | | {144,238,144,RGB(144,238,144)}, | | {224,255,255,RGB(224,255,255)}, | | {248, 29, 56,RGB(248, 29, 56)}, | | {255, 0,255,RGB(255, 0,255)}, | | {255,255, 0,RGB(255,255, 0)}, | | {255,255,255,RGB(255,255,255)} | | }; | | | | | | | | int getTIME(int i) | | { | | time_t timep; | | struct tm *p; | | time(&timep); | | p=localtime(&timep); | | | | switch(i) | | { | | case 0: | | return p->tm_year+1900; | | case 1: | | return p->tm_mon+1; | | case 2: | | return p->tm_mday; | | case 3: | | return p->tm_hour; | | case 4: | | return p->tm_min; | | case 5: | | return p->tm_sec; | | default: | | break; | | } | | } | | | | int getKEY(int N,int T) | | { | | int i,KEY_V,start=clock(); | | do | | { | | if(_kbhit()) | | { | | KEY_V=(int)(_getch()); | | if(KEY_V<97) | | { | | KEY_V+=32; | | } | | return KEY_V; | | } | | for(i=0; i<=N; i++); | | } | | while((clock()-start)<T); | | return -1; | | } | | | | static WCHAR Tainer[1024]= {0}; | | WCHAR* AnsiToWCHAR(const CHAR* str) | | { | | if(!str) | | { | | return NULL; | | } | | int wLen=MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, str, -1, NULL, 0); | | MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, str, -1, Tainer, wLen); | | Tainer[wLen]='\0'; | | return Tainer; | | } | | | | long long fact(long long n) | | { | | return (n<2) ?1 :n*(fact(n-1)); | | } | | | | inline BOOL isEND(const char c,const char* endstring) | | { | | if(c=='\0') | | { | | return TRUE; | | } | | | | while(*endstring!='\0') | | { | | if(c==*(endstring++)) | | { | | return TRUE; | | } | | } | | return FALSE; | | } | | | | char* passNULL(char* Str) | | { | | if(Str!=NULL) | | { | | while(*Str=='\t' ||*Str==' ') | | { | | Str++; | | } | | } | | return Str; | | } | | | | inline int errorEXIT(char* errorTYPE) | | { | | fprintf(stderr, "[%d]:%s '%s\n", CUR_LINENUM, errorTYPE, passNULL(CUR_LINEPOINTER)); | | exit(1); | | } | | | | BOOL isKEY(char* Line, char* key, const char* endstring) | | { | | char *op=Line, *kp=key; | | while(*kp!='\0') | | { | | if((('a'<= *op && *op<='z')?*op-32:*op) != (('a'<= *kp && *kp<='z')?*kp-32:*kp)) | | { | | break; | | } | | op++; | | kp++; | | } | | if( | | *kp=='\0' && | | isEND(*op, endstring) | | ) | | { | | return TRUE; | | } | | return FALSE; | | } | | | | int ARGS(char* Str, char** WORDS, int PRO_NUM, int LineNUM, char* Line) | | { | | if(PRO_NUM==0) | | { | | return 0; | | } | | | | int i=0; | | char* lp=Str; | | | | char* tp; | | strtok(lp, " \t"); | | | | WORDS[0]=(char*)calloc(MAX_WORDS_SIZE, sizeof(char)); | | strcpy(WORDS[0], ":\n"); | | | | while((++i)<PRO_NUM) | | { | | if((tp=strtok(NULL, " \t"))==NULL) | | { | | break; | | } | | WORDS[i]=(char*)calloc(MAX_WORDS_SIZE, sizeof(char)); | | strcpy(WORDS[i], tp); | | } | | | | | | if(i<PRO_NUM) | | { | | errorEXIT("Missing parameter"); | | } | | | | return i; | | } | | | | int ARGP(char* Str, double* WVALUE, int PRO_NUM, char** PRO_WORDS, double* PRO_VALUE) | | { | | int i=0; | | char* tp; | | strtok(Str, " \t"); | | while((tp=strtok(NULL, " \t"))!=NULL && *tp!='\0') | | { | | WVALUE[++i]=RevPolishCore(tp, PRO_NUM, PRO_WORDS, PRO_VALUE); | | } | | return i+1; | | } | | | | int Identify_KeyWords(char* Line, int SENSITIVE_NUM, char** WORDS, const char* endstring) | | { | | int SN; | | for(SN=0; SN<SENSITIVE_NUM; SN++) | | { | | char *op=Line, *kp=WORDS[SN]; | | while(*kp!='\0') | | { | | if( | | (('a'<= *op && *op<='z')?*op-32:*op) != (('a'<= *kp && *kp<='z')?*kp-32:*kp) | | ) | | { | | break; | | } | | op++; | | kp++; | | } | | if( | | *kp=='\0' && | | isEND(*op, endstring) | | ) | | { | | return SN; | | } | | } | | return -1; | | } | | | | | | | | double RevPolishCore(const char* expression, int PRO_NUM, char** WORDS, double* VALUE) | | { | | STACK3[0]=0; | | int si, brackets=0; | | char *op=(char*)expression, *S1=STACK1, *S2=STACK2, **key, *cp, *kp; | | double *S3=STACK3, di, ni; | | | | | | while(*op!='\0' && *op!=' ' && *op!='\t') | | { | | switch(*op) | | { | | case ' ' : | | case '\t': | | | | op++; | | continue; | | | | case 'a': | | case 'b': | | case 'c': | | case 'd': | | case 'e': | | case 'f': | | case 'g': | | case 'h': | | case 'i': | | case 'j': | | case 'k': | | case 'l': | | case 'm': | | case 'n': | | case 'o': | | case 'p': | | case 'q': | | case 'r': | | case 's': | | case 't': | | case 'u': | | case 'v': | | case 'w': | | case 'x': | | case 'y': | | case 'z': | | case 'A': | | case 'B': | | case 'C': | | case 'D': | | case 'E': | | case 'F': | | case 'G': | | case 'H': | | case 'I': | | case 'J': | | case 'K': | | case 'L': | | case 'M': | | case 'N': | | case 'O': | | case 'P': | | case 'Q': | | case 'R': | | case 'S': | | case 'T': | | case 'U': | | case 'V': | | case 'W': | | case 'X': | | case 'Y': | | case 'Z': | | | | key=(char**)MATH_WORDS; | | while(*key !=NULL) | | { | | cp=op, kp=*key; | | | | while((*cp==*kp||*cp==*kp+32) && *kp!='\0') | | { | | cp++, kp++; | | } | | | | if( ((*cp<'A')||('Z'<*cp && *cp<'a')||(*cp>'z')) && (*kp=='\0') ) | | { | | op=cp; | | break; | | } | | key++; | | } | | | | if(*key !=NULL) | | { | | *(S2++)='.'; | | *(S2++)=' '; | | | | while( ('A'<=(*S1) && (*S1)<='Z') ) | | { | | *(S2++)=*(S1--); | | } | | *(++S1)=key-(char**)MATH_WORDS+65; | | continue; | | } | | else | | { | | | | errorEXIT("Unrecognized math function"); | | } | | break; | | | | case '(': | | brackets++; | | *(++S1)=*op; | | if(*(op+1)=='-' || *(op+1)=='+') | | { | | *(S2++)='0', *(S2++)=' '; | | } | | break; | | | | case ')': | | brackets--; | | while(*S1!='(') | | { | | *(S2++)=*(S1--); | | } | | | | S1--; | | break; | | | | case '+': | | case '-': | | while(S1!=STACK1 && *S1!='(') | | { | | *(S2++)=*(S1--); | | } | | *(++S1)=*op; | | break; | | | | case '^': | | | | while( ('A'<=(*S1) && (*S1)<='Z') ) | | { | | *(S2++)=*(S1--); | | } | | *(++S1)=*op; | | break; | | | | case '%': | | case '*': | | case '/': | | while(('A'<=(*S1) && (*S1)<='Z') ||*S1=='%' ||*S1=='*' ||*S1=='/' ||*S1=='^') | | { | | *(S2++)=*(S1--); | | } | | *(++S1)=*op; | | break; | | | | case ':': | | | | for(si=PRO_NUM-1; si>=0-GLOBAL_SIZE; si--) | | { | | cp=op, kp=(si<0)?(char *)GLOBAL_WORDS[-1-si]:WORDS[si]; | | | | while((*cp==*kp||*cp==*kp+32) && *kp!='\0') | | { | | cp++, kp++; | | } | | | | if(!(('a'<=*cp && *cp<='z')||('A'<=*cp && *cp<='Z')||('0'<=*cp && *cp<='9')||(*cp=='_' || *cp=='#')) && (*kp=='\0')) | | { | | op=cp-1; | | break; | | } | | } | | | | if(si>=0-GLOBAL_SIZE) | | { | | | | *(S2++)=':', *(S2++)=si, *(S2++)=' '; | | } | | else | | { | | | | errorEXIT("Variable not exist"); | | } | | break; | | | | default : | | if((*op<'0' || *op>'9') && (*op!='.')) | | { | | | | errorEXIT("Unrecognized number"); | | } | | | | while(('0'<=*op && *op<='9') ||*op=='.') | | { | | *(S2++)=*(op++); | | } | | op--; | | *(S2++)=' '; | | break; | | } | | op++; | | } | | | | | | if(brackets) | | { | | errorEXIT("The brackets '(' or ')' are not closed"); | | } | | | | | | while(S1 !=STACK1) | | { | | *(S2++)=*(S1--); | | } | | *S2=' '; | | | | | | op=STACK2; | | while(*op!=' ') | | { | | switch(*op) | | { | | case 'A': | | if(*S3 <0 || *S3 >5) | | { | | | | errorEXIT("The 'time(n)' requires 'n' between 0 to 5"); | | } | | *(S3-1)=getTIME((int)*S3); | | S3--; | | break; | | case 'B': | | *S3=3.1415926535897932; | | break; | | case 'C': | | if(*S3 <0) | | { | | | | errorEXIT("Negative numbers have no square root"); | | } | | *(S3-1)=sqrt(*S3); | | S3--; | | break; | | case 'D': | | if(*S3 <0) | | { | | | | errorEXIT("Negative numbers are not logarithmic"); | | } | | *(S3-1)=log10(*S3); | | S3--; | | break; | | case 'E': | | if(*S3 <0) | | { | | | | errorEXIT("Negative numbers have no natural logarithms"); | | } | | *(S3-1)=log(*S3); | | S3--; | | break; | | case 'F': | | *(S3-1)=sin(*S3); | | S3--; | | break; | | case 'G': | | *(S3-1)=cos(*S3); | | S3--; | | break; | | case 'H': | | if(*S3==3.1415926535897932/2) | | { | | | | errorEXIT("The pi/2 has no tangent"); | | } | | *(S3-1)=tan(*S3); | | S3--; | | break; | | case 'I': | | *(S3-1)=asin(*S3); | | S3--; | | break; | | case 'J': | | *(S3-1)=acos(*S3); | | S3--; | | break; | | case 'K': | | *(S3-1)=atan(*S3); | | S3--; | | break; | | case 'L': | | *(S3-1)=(*S3)*3.1415926535897932/180.0; | | S3--; | | break; | | case 'M': | | *(S3-1)=fabs(*S3); | | S3--; | | break; | | case 'N': | | *(S3-1)=(*S3<=0)?(int)(*S3-0.5):(int)(*S3+0.5); | | S3--; | | break; | | case 'O': | | *(S3-1)=getKEY(50, (int)fabs(*S3)); | | S3--; | | break; | | case 'P': | | *(S3-1)=ceil(*S3); | | S3--; | | break; | | case 'Q': | | *(S3-1)=exp(*S3); | | S3--; | | break; | | case 'R': | | *(S3-1)=sinh(*S3); | | S3--; | | break; | | case 'S': | | *(S3-1)=cosh(*S3); | | S3--; | | break; | | case 'T': | | *(S3-1)=tanh(*S3); | | S3--; | | break; | | case 'U': | | *(S3-1)=log(*S3+sqrt((*S3)*(*S3)+1)); | | S3--; | | break; | | case 'V': | | *(S3-1)=log(*S3+sqrt((*S3)*(*S3)-1)); | | S3--; | | break; | | case 'W': | | *(S3-1)=log((1+(*S3))/(1-(*S3)))/2; | | S3--; | | break; | | case 'X': | | | | if(*S3 <0) | | { | | | | errorEXIT("A negative number can not be used as a random upper bound"); | | } | | else if(*S3 <2) | | { | | | | *(S3-1)=rand() % 1024 /1024.0; | | } | | else | | { | | *(S3-1)=rand() % (int)(*S3); | | } | | S3--; | | break; | | case 'Y': | | *(S3-1)=(int)(*S3); | | S3--; | | break; | | case 'Z': | | if(*S3 <0) | | { | | | | errorEXIT("Negative numbers have no factorial"); | | } | | *(S3-1)=fact((*S3)); | | S3--; | | break; | | case '+': | | *(S3-1)+=*S3; | | S3--; | | break; | | case '-': | | *(S3-1)-=*S3; | | S3--; | | break; | | case '*': | | *(S3-1)*=*S3; | | S3--; | | break; | | case '%': | | case '/': | | if(*S3 !=0) | | { | | if(*op=='%') | | { | | | | *(S3-1)=(int)*(S3-1) % (int)*S3; | | } | | else | | { | | *(S3-1)/=*S3; | | } | | | | } | | else | | { | | | | errorEXIT("Divisor is zero error"); | | } | | S3--; | | break; | | case '^': | | if(*(S3-1)==0 && *S3<0) | | { | | | | errorEXIT("Function pow's divisor is zero error"); | | } | | *(S3-1)=pow(*(S3-1), *S3); | | S3--; | | break; | | case ':': | | op++; | | *(++S3)=(*op<0)?GLOBAL_VALUE[-1-(*op)]:VALUE[*op]; | | op++; | | break; | | | | default : | | | | di=0, ni=1; | | while('0'<=*op && *op<='9') | | { | | di=10*di+(*op)-'0'; | | op++; | | } | | if(*op=='.') | | { | | op++; | | while('0'<=*op && *op<='9') | | { | | di=10*di+(*op)-'0'; | | op++, ni*=10; | | } | | } | | *(++S3)=di/ni; | | break; | | } | | op++; | | } | | | | if(isINF(*S3)||isNAN(*S3)) | | { | | errorEXIT("Overflow or illegal operation is calculated"); | | } | | | | | | return *S3; | | } | | | | BOOL AssignMent(const char* exp, int PRO_NUM, char** WORDS, double* VALUE) | | { | | char *op=(char*)exp, *ep=op, *cp, *kp; | | int si, i; | | | | | | while(!isEND(*(ep++), "=")) {;} | | | | if(op[0]==':') | | { | | if(op[1]==':') | | { | | | | errorEXIT("The loop variables '::' are not assignable"); | | } | | | | | | for(si=PRO_NUM-1; si>=0-GLOBAL_SIZE; si--) | | { | | cp=op, kp=(si<0)?(char *)GLOBAL_WORDS[-1-si]:WORDS[si]; | | | | while((*cp==*kp||*cp==*kp+32) && *kp!='\0') | | { | | cp++, kp++; | | } | | | | if( ((*cp==' ')||(*cp=='\t')||(*cp=='=')) && (*kp=='\0') ) | | { | | op=cp-1; | | break; | | } | | } | | | | if(si>=0-GLOBAL_SIZE) | | { | | | | if(si<0) | | { | | i=-1-si; | | GLOBAL_VALUE[i]=RevPolishCore(ep, PRO_NUM, WORDS, VALUE); | | STRGB* bgRGB; | | HBRUSH m_brush; | | switch(i) | | { | | case 3: | | if(GLOBAL_VALUE[i]<0 ||GLOBAL_VALUE[i]>15) | | { | | | | errorEXIT("The ':PENB' represents the background color, and only be between 0 to 15"); | | } | | bgRGB=&LOGO_RGB[(int)GLOBAL_VALUE[i]]; | | | | m_brush=CreateSolidBrush(bgRGB->VALUE); | | | | FillRect(hDC1, lrRECT, m_brush); | | | | DeleteObject(m_brush); | | break; | | case 4: | | if(GLOBAL_VALUE[i]<0 ||GLOBAL_VALUE[i]>99) | | { | | | | errorEXIT("The ':PENW' represents the width of the pen, and only be between 0 to 99"); | | } | | break; | | case 5: | | if(GLOBAL_VALUE[i]<0 ||GLOBAL_VALUE[i]>15) | | { | | | | errorEXIT("The ':PENC' represents the color of the pen, and only be between 0 to 15"); | | } | | break; | | case 6: | | if(GLOBAL_VALUE[i]<0 ||GLOBAL_VALUE[i]>5) | | { | | | | errorEXIT("The ':PENS' represents the smooth of the pen, and only be between 0 to 5"); | | } | | break; | | case 7: | | if(GLOBAL_VALUE[i]<0 ||GLOBAL_VALUE[i]>255) | | { | | | | errorEXIT("The ':PENA' represents the alpha of the pen, and only be between 0 to 255"); | | } | | break; | | default: | | break; | | } | | | | } | | else | | { | | | | VALUE[si]=RevPolishCore(ep, PRO_NUM, WORDS, VALUE); | | } | | | | } | | else | | { | | | | errorEXIT("Variable not exist"); | | } | | } | | return TRUE; | | } | | | | BOOL MoreAssignMent(const char* Line, int PRO_NUM, char** WORDS, double* VALUE) | | { | | if(Line[0] !=':') | | { | | errorEXIT("Variable not exist"); | | } | | char *gp=(char*)Line; | | while(isEND(*gp, ":")) | | { | | AssignMent(gp, PRO_NUM, WORDS, VALUE); | | gp++; | | while(!isEND(*gp, " \t\0")) | | { | | gp++; | | } | | while(!isEND(*gp, ":\0")) | | { | | gp++; | | } | | if(*gp=='\0') | | { | | return TRUE; | | } | | } | | return TRUE; | | } | | | | inline BOOL isForTrue(const char* Line, int PRO_NUM, char** WORDS, double* VALUE, int CYC) | | { | | if(CYC ==0) | | { | | return TRUE; | | } | | char *pCHA1, *pCHA2, *pCHA3; | | pCHA1=strtok((char*)Line, " \t"); | | pCHA2=strtok( NULL, " \t"); | | pCHA3=strtok( NULL, " \t"); | | if(pCHA3 !=NULL) | | { | | int i=Identify_KeyWords(pCHA1, PRO_NUM, WORDS, " \t"); | | if(i==-1) | | { | | errorEXIT("Variable not exist"); | | } | | int staNUM=RevPolishCore(pCHA2, PRO_NUM, WORDS, VALUE); | | int endNUM=RevPolishCore(pCHA3, PRO_NUM, WORDS, VALUE); | | int var =VALUE[i]; | | if(staNUM-endNUM<0) | | { | | return (var<=endNUM)?TRUE:FALSE; | | } | | return (var>=endNUM)?TRUE:FALSE; | | } | | else | | { | | errorEXIT("Needs more parameters"); | | } | | } | | | | BOOL JudgMent(const char* exp, int PRO_NUM, char** WORDS, double* VALUE) | | { | | char* op=CacheTain; | | char* cp=(char*)exp; | | | | | | while(*cp=='\t'|| *cp==' ') | | { | | cp++; | | } | | | | if(*cp =='\0') | | { | | return TRUE; | | } | | | | char* Line_Cache=op; | | int i=-1, flag=0; | | | | while(!isEND(*cp, " \t\0")) | | { | | | | switch(*cp) | | { | | case '!': | | flag+=8; | | break; | | case '>': | | if(flag==0||flag==8) | | { | | *(op++)='-', *(op++)='('; | | } | | flag+=4; | | break; | | case '<': | | if(flag==0||flag==8) | | { | | *(op++)='-', *(op++)='('; | | } | | flag+=2; | | break; | | case '=': | | if(flag==0||flag==8) | | { | | *(op++)='-', *(op++)='('; | | } | | flag+=1; | | break; | | default: | | *(op++)=*(cp++); | | continue; | | } | | cp++; | | } | | | | *(op++)=(flag!=8)?')':'\0'; | | *op='\0' ; | | | | float m=RevPolishCore(Line_Cache, PRO_NUM, WORDS, VALUE); | | | | switch(flag) | | { | | case 8: | | | | return (m==0)?TRUE:FALSE; | | case 4: | | return (m >0)?TRUE:FALSE; | | break; | | case 2: | | return (m <0)?TRUE:FALSE; | | break; | | case 1: | | return (m==0)?TRUE:FALSE; | | break; | | case 3: | | case 12: | | return (m<=0)?TRUE:FALSE; | | break; | | case 5: | | case 10: | | return (m>=0)?TRUE:FALSE; | | break; | | case 6: | | case 9: | | return (m!=0)?TRUE:FALSE; | | break; | | | | default: | | errorEXIT("Wrong logic"); | | } | | } | | | | BOOL MoreJudgMent(const char* Line, int PRO_NUM, char** WORDS, double* VALUE) | | { | | char *gp=(char*)Line; | | int li=Identify_KeyWords(gp, LGC_SIZE, (char**)LGC_WORDS, " \t"); | | if(li !=-1) | | { | | gp+=LGC_LLENS[li]; | | } | | | | do | | { | | while(isEND(*gp, " \t")) | | { | | gp++; | | } | | if(JudgMent(gp, PRO_NUM, WORDS, VALUE)) | | { | | | | switch(li) | | { | | case 0: | | return FALSE; | | case 1: | | break; | | case 2: | | return TRUE; | | default: | | return TRUE; | | } | | } | | else | | { | | switch(li) | | { | | case 0: | | break; | | case 1: | | return FALSE; | | case 2: | | break; | | default: | | return FALSE; | | } | | } | | while(!isEND(*gp, " \t\0")) | | { | | gp++; | | } | | if(*gp=='\0') | | { | | switch(li) | | { | | case 0: | | return TRUE; | | case 1: | | return TRUE; | | case 2: | | return FALSE; | | } | | } | | while(isEND(*gp, " \t")) | | { | | gp++; | | } | | | | } | | while(*gp !='\0'); | | } | | | | char* SuperPrintf(const char* pline, int PRO_NUM, char** WORDS, double* VALUE) | | { | | char* op=(char*)pline; | | char* cp; | | char* sp=Auxiliary; | | while(*op !='\0') | | { | | | | switch(*op) | | { | | case '\\': | | switch(*(++op)) | | { | | case 'b': | | case 'B': | | *(sp++)='\b'; | | break; | | case 'e': | | case 'E': | | *(sp++)='\0'; | | break; | | case 'r': | | case 'R': | | *(sp++)='\r'; | | break; | | case 'n': | | case 'N': | | *(sp++)='\n'; | | break; | | case 't': | | case 'T': | | *(sp++)='\t'; | | break; | | case '{': | | case '}': | | *(sp++)=*op; | | break; | | case '\\': | | *(sp++)='\\'; | | break; | | default: | | errorEXIT("Uninterpreted characters"); | | } | | break; | | case '{': | | op++, cp=CacheTain; | | while(*op!='\0' && *op!='}') | | { | | *(cp++)=*(op++); | | } | | if(*op=='\0') | | { | | errorEXIT("Missing '}'"); | | } | | | | *cp='\0'; | | sprintf(sp, "%.12g", RevPolishCore(CacheTain, PRO_NUM, WORDS, VALUE)); | | while(*(sp++)!='\0') {;} | | sp--; | | break; | | default: | | *(sp++)=*(op); | | break; | | } | | op++; | | } | | *(sp++)='\n', *(sp++)='\0'; | | return Auxiliary; | | } | | | | | | BOOL SizeCursor(int size) | | { | | CONSOLE_CURSOR_INFO cursor_info = {(DWORD)((size==0)?25:size), (size==0)?FALSE:TRUE}; | | return SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info); | | } | | | | void drawSMOOTHLINE(HDC hDC, float penWith, SmoothingMode mode, BYTE sharpMODE, BYTE alpha, STRGB* penRGB, float x1, float y1, float x2, float y2, float angel) | | { | | Graphics gp(hDC); | | gp.SetSmoothingMode(mode); | | Pen pen(Color(alpha,penRGB->R,penRGB->G,penRGB->B), penWith); | | | | if(angel !=0) | | { | | Matrix matrix; | | matrix.RotateAt(angel, PointF(x1, y1)); | | gp.SetTransform(&matrix); | | } | | switch(sharpMODE) | | { | | case 0: | | gp.DrawLine(&pen, PointF(x1, y1), PointF(x2, y2)); | | break; | | case 1: | | gp.DrawEllipse(&pen, RectF(x1-x2,y1-y2,x2*2,y2*2)); | | break; | | case 2: | | gp.DrawRectangle(&pen, RectF(x1-x2,y1-y2,x2*2,y2*2)); | | break; | | } | | DeleteObject(&pen); | | } | | | | BOOL drawLINE(HDC hDC, float d) | | { | | float x1=GLOBAL_VALUE[0], y1=GLOBAL_VALUE[1]; | | GLOBAL_VALUE[0]+=d * sin(GLOBAL_VALUE[2]*0.017453292519943); | | GLOBAL_VALUE[1]+=d * cos(GLOBAL_VALUE[2]*0.017453292519943); | | | | | | if(!penMODE) | | { | | return FALSE; | | } | | drawSMOOTHLINE(hDC, (float)GLOBAL_VALUE[4], (SmoothingMode)(int)GLOBAL_VALUE[6], 0, (BYTE)GLOBAL_VALUE[7], &LOGO_RGB[(int)GLOBAL_VALUE[5]], base_X+x1, base_Y-y1, base_X+GLOBAL_VALUE[0], base_Y-GLOBAL_VALUE[1], 0); | | return TRUE; | | } | | | | void backWARD(float d) | | { | | GLOBAL_VALUE[0]-=d * sin(GLOBAL_VALUE[2]*0.017453292519943); | | GLOBAL_VALUE[1]-=d * cos(GLOBAL_VALUE[2]*0.017453292519943); | | } | | | | int RotateDC(HDC hDC, double angle) | | { | | if(angle==0) | | { | | return 1; | | } | | XFORM Matrix; | | double rad =-angle * 0.017453292519943, rtmp1=base_X+GLOBAL_VALUE[0], rtmp2=base_Y-GLOBAL_VALUE[1]; | | Matrix.eM11 = (float)cos(rad); | | Matrix.eM12 = (float)sin(rad); | | Matrix.eM21 =-(float)sin(rad); | | Matrix.eM22 = (float)cos(rad); | | Matrix.eDx = (float)(rtmp1-cos(rad)*rtmp1+sin(rad)*rtmp2); | | Matrix.eDy = (float)(rtmp2-cos(rad)*rtmp2-sin(rad)*rtmp1); | | SetGraphicsMode(hDC, GM_ADVANCED); | | SetWorldTransform(hDC, &Matrix); | | return 0; | | } | | | | void drawTEXT(HDC hDC, int fontSIZE, int fontSTYLE, int fontCOLOR, char* fontNAME, char* pSTRING) | | { | | Graphics graphicsp(hDC), *graph=&graphicsp; | | FontFamily fontFAMILY(AnsiToWCHAR(fontNAME)); | | Font fontp(&fontFAMILY, fontSIZE, (FontStyle)fontSTYLE, UnitPixel); | | STRGB* txRGB=&LOGO_RGB[fontCOLOR]; | | SolidBrush brushp(Color((int)GLOBAL_VALUE[7], txRGB->R, txRGB->G, txRGB->B)); | | graph->DrawString(AnsiToWCHAR(pSTRING), -1, &fontp, PointF(base_X+GLOBAL_VALUE[0],base_Y-GLOBAL_VALUE[1]), &brushp); | | | | DeleteObject(&brushp); | | DeleteObject(&fontp); | | DeleteObject(&fontFAMILY); | | DeleteObject(&graphicsp); | | } | | | | | | | | BOOL FileScript(char* prossName, int PRO_NUM, double* PRO_VALUE) | | { | | | | int i=0, j=0, ki, KLevel=0, SN=-1, Line_LEN=0, fcolor=-1, BASE_VAR_NUM=PRO_NUM; | | float pTMP1, pTMP2, pTMP3, pTMP4, pTMP5, wTIME; | | char *prepos=NULL, *pCHA1, *pCHA2, *pCHA3, *pCHA4, *pCHA5; | | double tpadd; | | | | | | char** PRO_WORDS=(char**)calloc(LOOP_LEVELS, sizeof(char*)); | | | | | | char* SFLAG=(char*)calloc(8, sizeof(char)); | | SFLAG[2]=-1; | | | | | | int* FORI_CYCL=(int *)calloc(LOOP_LEVELS, sizeof(int )); | | int* FORI_LNUM=(int *)calloc(LOOP_LEVELS, sizeof(int )); | | char** FORI_FTEL=(char**)calloc(LOOP_LEVELS, sizeof(char*)); | | char** FORI_FEND=(char**)calloc(LOOP_LEVELS, sizeof(char*)); | | BOOL* FORI_IFOT=(BOOL *)calloc(LOOP_LEVELS, sizeof(BOOL )); | | | | | | char* LCache=(char*)calloc(1025, sizeof(char)); | | | | CUR_LINEPOINTER=LCache; | | | | | | char* Line; | | | | | | char* tmpfp=tRAM; | | | | while(*tmpfp !='\0') | | { | | | | | | char* prepos=tmpfp; | | | | | | Line=LCache; | | | | while(*tmpfp !='\n' && *tmpfp !='\0') | | { | | *(Line++)=*(tmpfp++); | | } | | if(*tmpfp =='\n') | | { | | tmpfp++; | | } | | *Line='\0'; | | | | Line=LCache; | | | | | | i++, CUR_LINENUM=i; | | | | | | while(*Line=='\t'|| *Line==' ') | | { | | Line++; | | } | | | | | | if( | | (Line[0]=='\0') || | | (Line[0]=='/' && Line[1]=='/') | | ) | | { | | continue; | | } | | | | | | if( | | (Line[0]=='/' &&Line[1]=='*') | | ) | | { | | SFLAG[3]=1; | | continue; | | | | } | | else if( | | (Line[0]=='*' &&Line[1]=='/') | | ) | | { | | SFLAG[3]=0; | | continue; | | | | } | | | | | | if( | | (isEND(Line[2], " \t\0") ) && | | (Line[0]=='T' || Line[0]=='t') && | | (Line[1]=='O' || Line[1]=='o') | | | | ) | | { | | Line+=2; | | | | | | while(*Line=='\t'|| *Line==' ') | | { | | Line++; | | } | | | | if(isKEY(Line, prossName, " \t\0")) | | { | | SFLAG[0]=1, SFLAG[4]=1; | | ARGS(Line, PRO_WORDS, PRO_NUM, i, Line); | | } | | else | | { | | SFLAG[0]=0; | | } | | continue; | | } | | | | | | if( | | SFLAG[0]==0 || | | SFLAG[3]==1 || | | Line[0]=='(' | | | | ) | | { | | continue; | | } | | | | | | | | if( | | (FORI_IFOT[KLevel+1] && SFLAG[1]==0) && | | (Line[0]!='E'&&Line[0]!='e') || | | (Line[1]!='L'&&Line[1]!='l') || | | (Line[2]!='I'&&Line[2]!='i') || | | (Line[3]!='F'&&Line[3]!='f') | | | | ) | | { | | FORI_IFOT[KLevel+1]=FALSE; | | } | | | | | | if(Line[0]==')') | | { | | if(KLevel>SFLAG[1]) | | { | | if(FORI_CYCL[KLevel] <0) | | { | | tpadd=RevPolishCore(Line+1, PRO_NUM, PRO_WORDS, PRO_VALUE); | | PRO_VALUE[0-FORI_CYCL[KLevel]]+=(tpadd==0)?1:tpadd; | | } | | if(FORI_FEND[KLevel]==NULL) | | { | | FORI_FEND[KLevel]=tmpfp; | | } | | tmpfp=FORI_FTEL[KLevel]; | | i=FORI_LNUM[KLevel]; | | | | } | | else | | { | | | | | | FORI_FTEL[KLevel]=NULL; | | FORI_FEND[KLevel]=NULL; | | FORI_CYCL[KLevel]=0; | | SFLAG[1]=0; | | } | | KLevel--; | | continue; | | | | } | | else | | { | | if((ki=Identify_KeyWords(Line, CYC_SIZE, (char**)CYC_WORDS, " \t\0")) !=-1) | | { | | Line=passNULL(Line+CYC_LLENS[ki]); | | KLevel++; | | | | if( | | ki==0 && FORI_CYCL[KLevel]<1 && MoreJudgMent(Line, PRO_NUM, PRO_WORDS, PRO_VALUE) || | | ki==1 && FORI_CYCL[KLevel]<RevPolishCore(Line, PRO_NUM, PRO_WORDS, PRO_VALUE) || | | ki==2 && MoreJudgMent(Line, PRO_NUM, PRO_WORDS, PRO_VALUE) || | | ki==3 && isForTrue(Line, PRO_NUM, PRO_WORDS, PRO_VALUE, FORI_CYCL[KLevel]) || | | ki==4 && (FORI_IFOT[KLevel]) && FORI_CYCL[KLevel]<1 && MoreJudgMent(Line, PRO_NUM, PRO_WORDS, PRO_VALUE) | | | | ) | | { | | if( FORI_FTEL[KLevel]==NULL ) | | { | | FORI_FTEL[KLevel]=prepos; | | FORI_LNUM[KLevel]=i-1; | | if(ki==3) | | { | | char *tp1, *tp2; | | | | if((tp1=strtok(Line, " \t"))==NULL) | | { | | errorEXIT("Missing parameter"); | | } | | PRO_WORDS[PRO_NUM]=(char*)calloc(MAX_WORDS_SIZE, sizeof(char)); | | strcpy(PRO_WORDS[PRO_NUM], tp1); | | | | if((tp2=strtok(NULL, " \t"))==NULL) | | { | | errorEXIT("Missing parameter"); | | } | | PRO_VALUE[PRO_NUM]=RevPolishCore(tp2, PRO_NUM, PRO_WORDS, PRO_VALUE); | | FORI_CYCL[KLevel] =0-PRO_NUM; | | PRO_NUM++; | | | | } | | if(ki==0 || ki==4) | | { | | FORI_IFOT[KLevel]=FALSE; | | } | | } | | | | if(ki !=3) | | { | | FORI_CYCL[KLevel] ++; | | } | | | | } | | else | | { | | if((ki==0) && FORI_CYCL[KLevel]==0) | | { | | FORI_IFOT[KLevel]=TRUE; | | } | | if(FORI_FEND[KLevel] !=NULL) | | { | | if(FORI_CYCL[KLevel] <0) | | { | | free(PRO_WORDS[PRO_NUM]); | | PRO_NUM-=1; | | } | | tmpfp=FORI_FEND[KLevel]; | | i=FORI_LNUM[KLevel]-1; | | FORI_FTEL[KLevel]=NULL; | | FORI_FEND[KLevel]=NULL; | | FORI_CYCL[KLevel]=0; | | KLevel--; | | } | | else | | { | | SFLAG[1]=KLevel; | | } | | } | | continue; | | } | | } | | | | | | if(SFLAG[1]!=0) | | { | | continue; | | } | | | | | | if((SN=Identify_KeyWords(Line, KEY_SIZE, (char**)KEY_WORDS, " \t\0")) !=-1) | | { | | Line=(SN==8)?Line+KEY_LLENS[SN]+1:passNULL(Line+KEY_LLENS[SN]); | | } | | else | | { | | | | | | double* PAR_VALUE=(double*)calloc(LOOP_LEVELS, sizeof(double)); | | | | if(! FileScript(Line, ARGP(Line, PAR_VALUE, PRO_NUM, PRO_WORDS, PRO_VALUE), PAR_VALUE) ) | | { | | fprintf(stderr, "[%d]:Undefined procedure name '%s\n", i, passNULL(LCache)); | | exit(1); | | } | | free(PAR_VALUE); | | continue; | | | | } | | switch(SN) | | { | | case 0: | | | | drawLINE(hDC, RevPolishCore(Line, PRO_NUM, PRO_WORDS, PRO_VALUE)); | | break; | | case 1: | | | | backWARD(RevPolishCore(Line, PRO_NUM, PRO_WORDS, PRO_VALUE)); | | break; | | case 2: | | | | GLOBAL_VALUE[2]-=RevPolishCore(Line, PRO_NUM, PRO_WORDS, PRO_VALUE); | | break; | | case 3: | | | | GLOBAL_VALUE[2]+=RevPolishCore(Line, PRO_NUM, PRO_WORDS, PRO_VALUE); | | break; | | case 4: | | | | penMODE=FALSE; | | break; | | case 5: | | | | if(SFLAG[2] !=-1) | | { | | GLOBAL_VALUE[5]=SFLAG[2]; | | SFLAG[2] =-1; | | } | | penMODE=TRUE; | | break; | | case 6: | | | | if(SFLAG[2] ==-1) | | { | | SFLAG[2]=GLOBAL_VALUE[5]; | | GLOBAL_VALUE[5]=GLOBAL_VALUE[3]; | | } | | break; | | case 7: | | | | InvalidateRect(hCMD, NULL, FALSE); | | GLOBAL_VALUE[0]=GLOBAL_VALUE[1]=GLOBAL_VALUE[2]=0; | | break; | | case 8: | | | | fputs(SuperPrintf(Line, PRO_NUM, PRO_WORDS, PRO_VALUE), stdout); | | break; | | case 9: | | | | GLOBAL_VALUE[0]=GLOBAL_VALUE[1]=GLOBAL_VALUE[2]=0; | | break; | | case 10: | | | | free(PRO_WORDS); | | free(SFLAG); | | free(FORI_CYCL); | | free(FORI_LNUM); | | free(FORI_FTEL); | | free(FORI_IFOT); | | free(LCache); | | return TRUE; | | case 11: | | | | exit(0); | | case 12: | | | | if((fcolor=RevPolishCore(Line, PRO_NUM, PRO_WORDS, PRO_VALUE)) !=-1) | | { | | | | STRGB* bgRGB=&LOGO_RGB[fcolor]; | | HBRUSH m_brush=CreateSolidBrush(bgRGB->VALUE); | | SelectObject(hDC1, m_brush); | | ExtFloodFill(hDC1, base_X+GLOBAL_VALUE[0], base_Y-GLOBAL_VALUE[1], GetPixel(hDC1,base_X+GLOBAL_VALUE[0],base_Y-GLOBAL_VALUE[1]),FLOODFILLSURFACE); | | | | DeleteObject(m_brush); | | } | | break; | | case 13: | | | | pCHA1=strtok(Line, " \t"), pCHA2=strtok(NULL, " \t"), pCHA3=strtok(NULL, " \t"), pCHA4=strtok(NULL, " \t"), pCHA5=strtok(NULL, " \t"); | | if(pCHA5 !=NULL) | | { | | pTMP1=RevPolishCore(pCHA1, PRO_NUM, PRO_WORDS, PRO_VALUE); | | pTMP2=RevPolishCore(pCHA2, PRO_NUM, PRO_WORDS, PRO_VALUE); | | pTMP3=RevPolishCore(pCHA3, PRO_NUM, PRO_WORDS, PRO_VALUE); | | drawTEXT(hDC, (int)fabs(pTMP1), (int)fabs(pTMP2)%5, (int)fabs(pTMP3)%16, pCHA4, SuperPrintf(pCHA5, PRO_NUM, PRO_WORDS, PRO_VALUE)); | | } | | else | | { | | errorEXIT("Needs more parameters"); | | } | | break; | | case 14: | | | | wTIME=RevPolishCore(Line, PRO_NUM, PRO_WORDS, PRO_VALUE); | | if(wTIME>0) | | { | | Sleep(wTIME); | | } | | else | | { | | getch(); | | } | | break; | | case 15: | | | | RotateDC(hDC1, (double)RevPolishCore(Line, PRO_NUM, PRO_WORDS, PRO_VALUE)); | | break; | | case 16: | | | | if(!memMODE) | | { | | BitBlt(hDC3,0,0,lrRECT->right,lrRECT->bottom, hDC1,0,0,SRCCOPY); | | memMODE=TRUE; | | } | | BitBlt(hDC2,0,0,lrRECT->right,lrRECT->bottom, hDC3,0,0,SRCCOPY); | | hDC=hDC2; | | break; | | case 17: | | | | BitBlt(hDC1,0,0,lrRECT->right,lrRECT->bottom, hDC2,0,0,SRCCOPY); | | BitBlt(hDC2,0,0,lrRECT->right,lrRECT->bottom, hDC3,0,0,SRCCOPY); | | break; | | case 18: | | | | memMODE=FALSE; | | hDC=hDC1; | | break; | | case 19: | | | | MoreAssignMent(passNULL(Line), PRO_NUM, PRO_WORDS, PRO_VALUE); | | break; | | case 20: | | | | pCHA1=strtok(Line, " \t"), pCHA2=strtok(NULL, " \t"); | | if(pCHA2 !=NULL) | | { | | pTMP1=RevPolishCore(pCHA1, PRO_NUM, PRO_WORDS, PRO_VALUE); | | pTMP2=RevPolishCore(pCHA2, PRO_NUM, PRO_WORDS, PRO_VALUE); | | if(penMODE) | | { | | drawSMOOTHLINE(hDC, (float)GLOBAL_VALUE[4], (SmoothingMode)(int)GLOBAL_VALUE[6], 0, (BYTE)GLOBAL_VALUE[7], &LOGO_RGB[(int)GLOBAL_VALUE[5]], base_X+GLOBAL_VALUE[0], base_Y-GLOBAL_VALUE[1], base_X+pTMP1, base_Y-pTMP2, 0); | | } | | GLOBAL_VALUE[0]=pTMP1, GLOBAL_VALUE[1]=pTMP2; | | | | } | | else | | { | | errorEXIT("Needs more parameters"); | | } | | break; | | case 21: | | | | pCHA1=strtok(Line, " \t"), pCHA2=strtok(NULL, " \t"), pCHA3=strtok(NULL, " \t"); | | if(pCHA3 !=NULL) | | { | | pTMP1=RevPolishCore(pCHA1, PRO_NUM, PRO_WORDS, PRO_VALUE); | | pTMP2=RevPolishCore(pCHA2, PRO_NUM, PRO_WORDS, PRO_VALUE); | | pTMP3=RevPolishCore(pCHA3, PRO_NUM, PRO_WORDS, PRO_VALUE); | | drawSMOOTHLINE(hDC, (float)GLOBAL_VALUE[4], (SmoothingMode)(int)GLOBAL_VALUE[6], 1, (BYTE)GLOBAL_VALUE[7], &LOGO_RGB[(int)GLOBAL_VALUE[5]], base_X+GLOBAL_VALUE[0], base_Y-GLOBAL_VALUE[1], pTMP1, pTMP2, pTMP3); | | | | } | | else | | { | | errorEXIT("Needs more parameters"); | | } | | break; | | case 22: | | | | pCHA1=strtok(Line, " \t"), pCHA2=strtok(NULL, " \t"), pCHA3=strtok(NULL, " \t"); | | if(pCHA3 !=NULL) | | { | | pTMP1=RevPolishCore(pCHA1, PRO_NUM, PRO_WORDS, PRO_VALUE); | | pTMP2=RevPolishCore(pCHA2, PRO_NUM, PRO_WORDS, PRO_VALUE); | | pTMP3=RevPolishCore(pCHA3, PRO_NUM, PRO_WORDS, PRO_VALUE); | | drawSMOOTHLINE(hDC, (float)GLOBAL_VALUE[4], (SmoothingMode)(int)GLOBAL_VALUE[6], 2, (BYTE)GLOBAL_VALUE[7], &LOGO_RGB[(int)GLOBAL_VALUE[5]], base_X+GLOBAL_VALUE[0], base_Y-GLOBAL_VALUE[1], pTMP1, pTMP2, pTMP3); | | | | } | | else | | { | | errorEXIT("Needs more parameters"); | | } | | break; | | | | default: | | errorEXIT("Error line"); | | } | | } | | if(!(BOOL)SFLAG[4]) | | { | | return FALSE; | | } | | free(PRO_WORDS); | | free(SFLAG); | | free(FORI_CYCL); | | free(FORI_LNUM); | | free(FORI_FTEL); | | free(FORI_IFOT); | | free(LCache); | | return TRUE; | | } | | | | | | int main(int argc, char** argv) | | { | | if(argc!=2) | | { | | | | fputs("COPYRIGHT@2017~2019 BY HAPPY, VERSION 1.0\nUSAGE: COOL [FILE]\n", stdout); | | return 1; | | } | | | | | | FILE* fp=fopen(argv[1], "r"); | | if(fp==NULL) | | { | | fputs("Failed to read file.", stdout); | | return 2; | | } | | | | SizeCursor(0); | | | | | | int fsize=0; | | fseek(fp, 0, SEEK_END); | | fsize=ftell(fp); | | | | fseek(fp, 0, SEEK_SET); | | | | if(fsize > 1*1024*1024) | | { | | fputs("File size is too large, out of memory.", stdout); | | return 1; | | } | | | | | | tRAM=(char*)malloc((fsize+1)*sizeof(char)); | | fread(tRAM, fsize, 1, fp); | | tRAM[fsize]='\0'; | | | | fclose(fp); | | | | | | srand((unsigned)time(NULL)); | | | | | | ULONG_PTR gdipludToken; | | GdiplusStartupInput gdiplusInput; | | GdiplusStartup(&gdipludToken,&gdiplusInput,NULL); | | | | { | | | | hCMD=GetConsoleWindow(); | | | | lrRECT=&winRECT; | | GetClientRect(hCMD, lrRECT); | | | | base_X=lrRECT->right/2, base_Y=lrRECT->bottom/2; | | lrRECT->right=base_X*2, lrRECT->bottom=base_Y*2; | | | | | | hDC1=GetDC(hCMD); | | HBITMAP hBitmap1=CreateCompatibleBitmap(hDC1, lrRECT->right, lrRECT->bottom); | | SelectObject(hDC1, hBitmap1); | | | | | | hWND2=NULL; | | hDC2=CreateCompatibleDC(GetDC(hWND2)); | | HBITMAP hBitmap2=CreateCompatibleBitmap(hDC1, lrRECT->right, lrRECT->bottom); | | SelectObject(hDC2, hBitmap2); | | | | | | hWND3=NULL; | | hDC3=CreateCompatibleDC(GetDC(hWND3)); | | HBITMAP hBitmap3=CreateCompatibleBitmap(hDC1, lrRECT->right, lrRECT->bottom); | | SelectObject(hDC3, hBitmap3); | | | | | | double* PAR_VALUE=(double*)calloc(LOOP_LEVELS, sizeof(double)); | | | | | | hDC=hDC1; | | | | | | FileScript("MAIN", 1, PAR_VALUE); | | | | | | ReleaseDC(NULL, hDC3); | | ReleaseDC(NULL, hDC2); | | ReleaseDC(hCMD, hDC1); | | DeleteDC(hDC3); | | DeleteDC(hDC2); | | DeleteDC(hDC1); | | DeleteObject(hBitmap3); | | DeleteObject(hBitmap2); | | DeleteObject(hBitmap1); | | | | free(PAR_VALUE); | | free(tRAM); | | } | | | | | | GdiplusShutdown(gdipludToken); | | return 0; | | }COPY |
|