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

📄 compile.cpp

📁 c语言的简化编译器
💻 CPP
字号:
// Test_VM.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"

#include <stdio.h>
#include <stdlib.h>
#include "error.h"
#include "pretty.h"
#include "tree.h"
#include "symbol.h"
#include "weed.h"
#include "type.h"
#include "resource.h"
#include "emit.h"
#include "code.h"
#include "memory.h"
#include "assembler.h"

int yyparse();

struct SCRIPTCOLLECTION *thescriptcollection;

int _tmain(int argc, _TCHAR* argv[])
{
	/* debugging */
  char *source = "2.prg";
  char *dest = "1.c";

  setbuf(stdout, NULL);
  setbuf(stderr, NULL);
  generateSymbol_SysFun();
  
//  if(argc < 3){
//    printf("Usage: u1comp <infile> <outfile>\n");
//    exit(1);
//  } 
//  else {
//    if(freopen(argv[1],"r",stdin) != NULL){
    if(freopen(source,"r",stdin) != NULL){  
      printf("// Parsing...\n");
      lineno=1;
      yyparse(); /* Build AST */
    }
    else {
//      printf("Couldn't open file %s\n",argv[1]);
      exit(1);
    }
//  }
  errorCheck();

  printf("// Weeding...\n");
  weedSCRIPTCOLLECTION(thescriptcollection);
  errorCheck();

  printf("// Symbolchecking...\n");
  symSCRIPTCOLLECTION(thescriptcollection);
  errorCheck();

  printf("// Typechecking...\n");
  typeSCRIPTCOLLECTION(thescriptcollection);
  errorCheck();

  /*
  printf("// Prettyprinting...\n");
  prettySCRIPTCOLLECTION(thescriptcollection);
  errorCheck();
  */
  printf("// Resource calculations...\n");
  resSCRIPTCOLLECTION(thescriptcollection);
  errorCheck();

  printf("// Coding...\n");
  codeSCRIPTCOLLECTION(thescriptcollection);
  errorCheck();

  printf("// Emitting (asm)...\n");
  emitSCRIPTCOLLECTION(thescriptcollection);
  errorCheck();
  
  printf("// Assembling...\n");
  //AssembleFile(argv[2]);
  AssembleFile(dest);
  
	return 0;
}

⌨️ 快捷键说明

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