資源簡介
編譯原理大作業(yè) 完整編譯器
詞法分析 語法分析 語義分析
簡單繪圖語言

代碼片段和文件信息
//#ifdef?_VC_COMPILER
#include?“semantics.h“
#define?MAX_CHARS?200
HWND?hwnd;
char?SrcFilePath[MAX_CHARS];
static?char?Name[]=“Compiler“;
static?bool?PrepareWindow(HINSTANCEHINSTANCEint);
static?bool?CheckSrcFile(LPSTR);
static?LRESULT?CALLBACK?WndProc(HWNDUINTWPARAMLPARAM);
int?APIENTRY?WinMain(HINSTANCE?hInstance
?HINSTANCE?hPrevInstance
?LPSTR?????lpCmdLine
?int???????nCmdShow)
{
strcpy(SrcFilePathlpCmdLine);
if(PrepareWindow(hInstancehPrevInstancenCmdShow)?!=?true)
{
MessageBox(NULL“窗口初始化失敗?!““錯(cuò)誤“MB_OK);
return?1;
}
if(!CheckSrcFile(lpCmdLine))return?1;
Parser(SrcFilePath);
????MSG?Msg;
while(GetMessage(&MsgNULL00))
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return?Msg.wParam;
}
bool?PrepareWindow(HINSTANCE?hInstHINSTANCE?hPrevInstanceint?nCmdShow)
{
HWND hWnd;
WNDCLASS?W;
memset(&W0sizeof(WNDCLASS));
W.style=CS_HREDRAW?|?CS_VREDRAW;
W.lpfnWndProc=WndProc;
W.hInstance=hInst;
W.hCursor=LoadCursor(NULLIDC_ARROW);
W.hbrBackground=(HBRUSH)(COLOR_WINDOW+1);
W.lpszClassName=Name;
RegisterClass(&W);
hWnd=CreateWindow(NameNameWS_OVERLAPPEDWINDOW1010740490NULLNULLhInstNULL);
if(hWnd==NULL)return?false;
ShowWindow(hWndnCmdShow);
UpdateWindow(hWnd);
SetCursor(LoadCursor(hInstIDC_ARROW));
hDC=GetDC(hWnd);
return?true;
}
bool?CheckSrcFile(LPSTR?lpszCmdParam)
{
FILE?*?file=NULL;
if(strlen(lpszCmdParam)==0)
{
MessageBox(NULL“未指定源程序文件?!““錯(cuò)誤“MB_OK);
return?false;
}
if((file=fopen(lpszCmdParam“r“))==NULL)
{
MessageBox(NULL“打開源程序文件出錯(cuò)?!““錯(cuò)誤“MB_OK);
MessageBox(NULLlpszCmdParam“文件名“MB_OK);
return?false;
}
else?fclose(file);
return?true;
}
LRESULT?CALLBACK?WndProc(HWND?hWndUINT?MessageWPARAM?wparamLPARAM?lparam)
{
switch(Message)
{
case?WM_DESTROY:
ReleaseDC(hWndhDC);
PostQuitMessage(0);
return?0;
break;
case?WM_PAINT:
PAINTSTRUCT?pt;
BeginPaint(hWnd&pt);
Parser(SrcFilePath);
EndPaint(hWnd&pt);
default?:
return?DefWindowProc(hWndMessagewparamlparam);
}
}
//#endif
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件???????4335??2007-05-25?12:39??COMPLIER\COMPLIER.dsp
?????文件????????524??2007-05-24?23:29??COMPLIER\COMPLIER.dsw
?????文件?????123904??2007-06-24?23:37??COMPLIER\COMPLIER.ncb
?????文件??????54784??2007-06-24?23:37??COMPLIER\COMPLIER.opt
?????文件????????250??2007-06-01?09:26??COMPLIER\COMPLIER.plg
?????文件???????2205??2007-06-02?12:23??COMPLIER\main.cpp
?????文件??????11195??2007-05-25?12:38??COMPLIER\parser.cpp
?????文件????????495??2007-05-25?12:38??COMPLIER\parser.h
?????文件???????4273??2007-05-24?23:19??COMPLIER\scanner.cpp
?????文件???????1923??2007-05-24?23:19??COMPLIER\scanner.h
?????文件???????3143??2007-05-27?19:01??COMPLIER\semantic.cpp
?????文件????????672??2007-05-24?23:19??COMPLIER\semantics.h
?????文件????????951??2007-06-02?00:07??COMPLIER\text.txt
?????目錄??????????0??2008-05-20?21:28??COMPLIER
-----------?---------??----------?-----??----
???????????????208872????????????????????15
評論
共有 條評論