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

📄 comexception.cs

📁 c--解释器
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.Text;

namespace compiler
{
    class ComException : Exception
    {
        //所在行
        int row;

        //所在列
        int col;

        //异常类型
        int expType;

        //信息
        string displayWord;
        
        //constructor

        public ComException(int rowfrom, int colfrom, int expTypefrom)
        {
            this.row = rowfrom;
            this.col = colfrom;
            this.expType = expTypefrom;
            this.displayWord = "There is a mistake at row " + this.row + "column" + this.col
                               + "the Error type is " + this.getTypeString();



        }

        public ComException(int rowfrom, int expTypefrom)
        {
            this.row = rowfrom;
            
            this.expType = expTypefrom;
            this.displayWord = "There is a mistake at row " + this.row +"  "
                               + "the Error type is " + this.getTypeString();



        }

      /*  void display() 
        {
            string displayWord = "There is a mistake at row " + this.row + "column" + this.col;
            
        
        }
        */


        //返回信息
        public string getMessage() 
        {
            return this.displayWord;
        
        }

        //返回错误类型
        public string getTypeString() 
        { 
          switch(this.expType)
          {
              case 0: return "confused error";

              case 1: return "常量定义错误";
                  
              case 2: return "漏掉分号";
                 
              case 3: return "漏掉‘]’";
                  
              case 4: return "数组定义错误";
              
              case 5: return "变量定义错误";

              case 6: return "方法头错误";
              
              case 7: return "方法体错误";
              case 8: return "表达式错误";
              case 9: return "漏掉 } ";
              case 10: return "数字类型错误";
                  
              default: return "wrong";
                 
          
          }
        
        }

    }
}

⌨️ 快捷键说明

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