unit1.cpp

来自「利用flex和bison做的简易C语言编译器核心 支持C语言的大部分运算操作」· C++ 代码 · 共 56 行

CPP
56
字号
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"

#ifndef DEBUG_PRINT_TOKEN
#define DEBUG_PRINT_TOKEN
#endif/*DEBUG_PRINT_TOKEN*/

#include "calc_flex.c"
#include "calc_yacc.c"
//---------------------------------------------------------------------------
long g_LabCount = 0;

void zzlabel(char *s)
{
    sprintf(s, "%04d", g_LabCount ++);
}
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
FILE *asout = NULL;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
        this->Memo1->Lines->SaveToFile("temp_i.txt");

        yyin  = fopen("temp_i.txt", "r+");
        yyout = fopen("temp_o.txt", "w+");
        asout = fopen("uasm_o.txt", "w+");

        //while(yylex());

        yyparse();

        fclose(yyin);
        fclose(yyout);
        fclose(asout);

        this->Memo2->Clear();
        this->Memo2->Lines->LoadFromFile("temp_o.txt");

        this->Memo3->Clear();
        this->Memo3->Lines->LoadFromFile("uasm_o.txt");
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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