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

📄 checkc.c

📁 一个程序拿来对一个C文件做基本的语法检查
💻 C
字号:
#include <stdio.h>#include <string.h>#include "Stack.h"#define cMAX_BUFFER_SIZE   1024int main(int argc, char *argv[]){    FILE *fp;    BYTE aBuffer[cMAX_BUFFER_SIZE];	BYTE *pTmp, *pEnd;	UINT32 dwByteRead, line = 1;    TOKEN token, preferToken = NONE;    if(2 != argc){       printf("Bad command format!\n");       printf("checkc <sourcefile> \n");       return 1;    }    if(NULL == (fp = fopen(argv[1], "r"))){        printf("The source file doesn\'t exist or have no permission to access it.\n");        return 2;    }    while(!feof(fp)){		memset(aBuffer, 0, cMAX_BUFFER_SIZE);        dwByteRead = fread(aBuffer, 1, cMAX_BUFFER_SIZE, fp);		pTmp = &aBuffer[0];		pEnd = pTmp + dwByteRead;		while(NONE != (token = GetNextToken(&pTmp, pEnd, preferToken))){			if(Newline == token)
				line++;

			if(isTokenMatchTop(token)){				pop();
				preferToken = NONE;
			}			else{
				switch(token){
					case SingleQuotation:
					case DoubleQuotation:
						push(token, line);
						preferToken = token;
						break;
					case LeftCommentLine:
						push(token, line);
						preferToken = RightCommentLine;
						break;
					case DoubleSlashComment:
						push(token, line);
						preferToken = Newline;
						break;
					case Newline:
						break;
					default:						push(token, line);						preferToken = NONE;
						break;
				}			}		}    }    fclose(fp);        PrintError();
	return 0; }

⌨️ 快捷键说明

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