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

📄 caslutil.h

📁 这是一个软件水平资格考试中使用的CASL汇编语言的编译器,实现文件中包括一个编译器,一个虚拟机,一个类似于Debug的调试器.
💻 H
字号:
#ifndef __CASL_UTIL_DEF
#define __CASL_UTIL_DEF
// 功能描述: 提供一些共通功能函数
// 开发人员: 杨军
// 开发日期: 2004-3-18
#include "CaslCompiler.h"

namespace CaslUtil 
{
  typedef enum  {
    CASL_UTIL_OP_OK = 0 ,  //操作成功
    STRING_NULL,            //字符串为空
    STRING_TOO_LONG,        //字符串过长
    STRING_TOO_SHORT,       //字符串过短
    STRING_CONST_INVALID,   //字符串常量格式不正确
    HEX_CONST_INVALID,      //十六进制常量格式不正确
    OPEN_FILE_FAILED        //打开文件失败
    
  } CaslUtilStatus;  //Casl工具类操作状态标志值

  //完成Casl编译器工作前的一些初始化工作
  //如设置全局变量的默认值等
  CaslUtilStatus CaslCompilerInitialize();
  //获得字符串常量的实际数值(实际上就是去除字符串两边的单引号) 
  CaslUtilStatus GetValueOfStringConst(char * argSrc);
  //获得十六进制常量的实际数值
  CaslUtilStatus GetValueOfHexConst(const char * argSrc, int& argDataOut);
  //依据中间代码变量表生成变量标号表,供生成目标代码使用
  CaslUtilStatus MakeVariableLabelTable(const vector<CaslVariable>& argVecSrc, vector<VariableLabelItem>& argVecDst);
  //依据中间代码常量表生成常量标号表,供生成目标代码使用
  CaslUtilStatus MakeConstLabelTable(const vector<CaslConst>& argVecSrc, vector<ConstLabelItem>& argVecDst);
  //依据中间代码指令标号表生成目标代码指令标号表,供生成目标代码使用
  CaslUtilStatus MakeInstructionLabelTable(const LabelMap& argMapSrc, vector<InstructionLabelItem>& argVecDst);
  //生成目标代码
  CaslUtilStatus MakeObjectCode();
  //以当前的目标代码和常量表及变量表生成指定名称的Casl程序的可执行文件
  CaslUtilStatus WriteExeFile(string szFileName);
  //在变量标号表中查询有无指定的变量标号记录
  int LookUpInVariableLableTable(vector<VariableLabelItem>& argVec, const CaslString argLabelName);
  //在常量标号表中查询有无指定的常量标号记录
  int LookUpInConstLableTable(vector<ConstLabelItem>& argVec, const CaslString argLabelName);
  //在指令标号表中查询有无指定的指令标号记录
  int LookUpInInstructionLableTable(vector<InstructionLabelItem>& argVec, const CaslString argLabelName);   
 
  //---------------------处理内存不足使用的函数begins-----------------------------------
  //设置新的new  handler
  void SetNewHandler();
  //新的new handler----提示用户没有足够的内存执行new 操作
  void NoEnoughMemory();
  //恢复以前的 new handler
  void RestoreNewHandler();
  //---------------------处理内存不足使用的函数ends--------------------------------------

  //--------------------字符串操作函数 begins------------------------------------------------
  //清除字符串左右两端的空格
  int Trim(string& argData);
  //清除字符串左端的空格
  int LTrim(string& argData);
  //清除字符串右的空格
  int RTrim(string& argData);
  //将字符串转化为大写
  int MakeUpperCase(string& argData);
  //将字符串转化为小写
  int MakeLowerCase(string& argData);
  //--------------------字符串操作函数 ends------------------------------------------------

  //-------------------完成错误消息的合并--------------------------------------------------------
  void MergeErrMsg(vector<CompilingErrMsg>& argDetailMsg, const vector<CompilingErrMsg>& argUnknownMsg);
};  //Casl工具类的名字空间

#endif

⌨️ 快捷键说明

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