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

📄 errors.h

📁 一个面向对像语言的编译器
💻 H
字号:
/*
 * File: errors.h
 * --------------
 * This file defines a set of error strings for use in producing the
 * same wording/spelling as our error messages and thus enabling diff
 * to easily compare your output against ours. Please be sure to
 * use these string constants when reporting errors.
 */

#ifndef _H_errors
#define _H_errors

// Errors used by scanner
static const char *err_unterm_comment = "Input ends with unterminated comment.";
static const char *err_newLine_string = "Illegal newline in string constant %s";
static const char *err_unterm_string = "Unterminated string constant: %s";
static const char *err_unrecog_char = "Unrecognized char: \'%c\'";

// Declarations
static const char *err_decl_conflict = "declaration of '%s' here conflicts with earlier declaration on line %d";
static const char *err_param_conflict = "identifier '%s' already used in this parameter list";
static const char *err_class_not_found = "class '%s' not found";
static const char *err_var_not_declared = "undeclared variable '%s'";
static const char *err_void_type = "cannot declare identifier '%s' as void type"; 


// Expressions
static const char *err_incompat_operands = "incompatible operands: %s %s %s"; // type op type, e.g. int < double
static const char *err_incompat_unary_op =  "incompatible operand: %s %s"; // op type, e.g. ! int

// Arrays
static const char *err_arr_brackets = "[] can only be applied to arrays";
static const char *err_base_void = "array base type must be non-void type";
static const char *err_length_array1 = "'length' can only be applied to arrays";
static const char *err_length_array2 = "function 'length' expects 0 argument(s) but %d given";
static const char *err_arr_subscript = "array subscript must be an integer";
static const char *err_new_array1 = "first argument to NewArray must be an integer";
static const char *err_new_array2 = "second argument to NewArray must be non-void type";

// Functions
static const char *err_non_fn = "%s is not a function";
static const char *err_fn_not_declared = "undeclared function '%s'";
static const char *err_override_mismatch = "overridden method '%s' must match inherited type signature";
static const char *err_fn_arg_count = "function '%s' expects %d argument(s) but %d given";
static const char *err_fn_arg_type = "incompatible argument %d: %s given, %s expected"; //argIndex type type, e.g. argument 3: int given, int[] expected 
static const char *err_fn_return = "incompatible return: %s given, %s expected";

// Field access
static const char *err_non_class = "cannot access field '%s' from %s";
static const char *err_non_method = "'%s' is not a method in class '%s'";
static const char *err_field_not_found = "field '%s' not found in %s";
static const char *err_field_access = "field '%s' of %s not accessible here";

// Misc 
static const char *err_new_arg = "argument to New must be class type";
static const char *err_print_arg = "incompatible argument %d: %s given, int/bool/string expected";
static const char *err_bool_required  = "test expression must have boolean type";
static const char *err_break = "'break' is only allowed inside a loop";
static const char *err_this = "'this' is  only allowed inside a class";

// Linker errors
static const char *err_meth_undefined = "Link error: method '%s' of class %s not defined";
static const char *err_fn_undefined = "Link error: function '%s' not defined";

// Runtime errors
static const char *err_arr_out_of_bounds = "Decaf runtime error: Array subscript out of bounds\n";
static const char *err_arr_neg_size = "Decaf runtime error: Cannot create negative-sized array\n";

// Specific to code gen project
static const char *err_no_code_gen_for_doubles = "Code generation for doubles is not supported";
  

#endif

⌨️ 快捷键说明

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