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

📄 unit1.h

📁 针对C++的简单词法分析器,局限性较大,算法简单,易懂,导入词法文件,输出分析结果
💻 H
字号:
//---------------------------------------------------------------------------

#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <Dialogs.hpp>
#include <string.h>
#define N 100//定义要分析的标识符或常数的最大个数
#define M 20 //标识符的长度
int line;int bufnum;
//---------------------------------------------------------------------------
 char *key[34]={"","auto","break","case","char","const","continue","default","do","double",
"else","enum","extern","float","for","goto","if","int","long","register",
"return","short","signed","sizeof","static","struct","switch","typedef",
"union","unsigned","void","volatile","while"}; /*C语言所有关键字*/
        char *border[6]={",",";","{","}","(",")"};//界符定义
        char *arithmetic[4]={"+","-","*","/"};//算术运算符定义
        char *relation[6]={"<","<=","=",">",">=","<>"};//关系运算符定义
        char *consts[N];//常数定义
        char *label[N];//标识符
        int constnum=0,labelnum=0;//constnum-常数个数;labelnum-标识符个数
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published:	// IDE-managed Components
        TOpenDialog *OpenDialog1;
        TSaveDialog *SaveDialog1;
        TMemo *Memo1;
        TMemo *Memo2;
        TButton *Button1;
        TButton *Button2;
        TButton *Button3;
        TButton *Button4;
        TButton *Button5;
        void __fastcall Button1Click(TObject *Sender);
        void __fastcall Button2Click(TObject *Sender);
        void __fastcall Button3Click(TObject *Sender);
        void __fastcall Button5Click(TObject *Sender);
        void __fastcall Button4Click(TObject *Sender);
        int __fastcall Isletter(char ch);
         int __fastcall IsDigit(char ch);
         int __fastcall search(char searchchar[],int wordtype);
         char __fastcall alphaprocess(char buffer,char *bufs);
         char __fastcall digitprocess(char buffer,char *bufs);
         char __fastcall otherprocess(char buffer,char *bufs);
private:






	// User declarations
public:
         // User declarations
        __fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif

⌨️ 快捷键说明

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