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

📄 error.cpp

📁 c语言的简化编译器
💻 CPP
字号:
/* wig error.c
 *
 * history:
 * 17.10.2000 created, defined yyerror()
 */
#include "stdafx.h"

#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include "error.h"

extern char *yytext;

int lineno = 0;

int errors = 0;

void yyerror(const char *format, ...)
{
  va_list argList;
  
  va_start(argList, format);
  vfprintf(stderr, format, argList);
  va_end(argList);
  
  fprintf(stderr, "\n");
  fprintf(stderr, "*** syntax error before %s at line %i\n", yytext, lineno);
  fprintf(stderr, "*** compilation terminated\n");
  
  exit(1);
}

void reportError(int lineno, const char *format, ...)
{
  va_list argList;

  fprintf(stderr, "*** Error: ");
  
  va_start(argList, format);
  vfprintf(stderr, format, argList);
  va_end(argList);
  
  fprintf(stderr, " at line %i\n", lineno);

  errors++;
}

void reportWarning(int lineno, const char *format, ...)
{
  va_list argList;

  fprintf(stderr, "*** Warning: ");
  
  va_start(argList, format);
  vfprintf(stderr, format, argList);
  va_end(argList);
  
  fprintf(stderr, " at line %i\n", lineno);
}

void errorCheck()
{
  if (errors!=0) {
  fprintf(stderr, "*** %i error(s) encountered, compilation terminated\n",errors);
     exit(1);
  }
}

⌨️ 快捷键说明

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