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

📄 main.cpp

📁 一个面向对像语言的编译器
💻 CPP
字号:
/* File: main.cc
 * -------------
 * This file defines the main() routine for the program and not much else.
 * You should not need to modify this file.
 */
 
#include "scanner.h"
#include "utility.h"
#include <string.h>
#include <stdio.h>
#include "parser.h"

static void ParseCommandLine(int argc, char *argv[]);

void  Clearyyparse()
{
	
}



/*
 * Function: main()
 * ----------------
 * Entry point to the entire program.  We parse the command line and turn
 * on any debugging flags requested by the user when invoking the program.
 * Call Inityylex() to set up the scanner, Inityyparse() to set up the parser,
 * and then call yyparse() to parse a valid program from the input. Returns
 * 0 if parsed successfully and no errors, -1 otherwise
 */
int main(int argc, char *argv[])
{
  ParseCommandLine(argc, argv);
  Inityylex();
  Inityyparse();
  int n=((yyparse() == 0 && numErrors == 0) ? 0 : -1);
  Clearyyparse();
  return n;
}


/*
 * Function: ParseCommandLine
 * --------------------------
 * Turn on the debugging flags from the command line.  Verifies that
 * first argument is -d, and then interpret all the arguments that follow
 * as being flags to turn on.
 */
static void ParseCommandLine(int argc, char *argv[])
{
  int i;
  
  if (argc == 1) 
    return;
  
  if (strcmp(argv[1], "-d") != 0) { // first arg is not -d
    printf("Usage:   -d <debug-key-1> <debug-key-2> ... \n");
    exit(2);
  }

  for (i = 2; i < argc; i++) 
    SetDebugForKey(argv[i], true);
}

⌨️ 快捷键说明

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