?? jsglobal_h.h
字號:
//---------------------------------------------------------------------------
//-------- JsGlobal_H.h -----------------------------------------------------
//---------------------------------------------------------------------------
#ifndef JsGlobal_H.h
#define JsGlobal_H.h
//---------------------------------------------------------------------------
#include <iostream.h>
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
//---------------------------------------------------------------------------
#include "Jtypes_H.h"
//---------------------------------------------------------------------------
#define DebugVer(str) str
#define WaitEnter DebugVer(getchar())
#define Waitkey DebugVer(getch())
#define Debugkey //Waitkey
#define Assertion(str) DebugVer(str)
#define Assert(str) Assertion(str)
#define DebugGlob(str) DebugVer(str)
#define DebugMsg(str) //DebugGlob(str)
#define ExceptionDetect(str) DebugVer(str)
#define EThrows(str) ExceptionDetect(str)
//---------------------------------------------------------------------------
#define MyVersion "0.12"
//---------------------------------------------------------------------------
#include "Jstring_H.h"
#include "Tokens_H.h"
//---------------------------------------------------------------------------
struct OPset
{ int8u OPnum; // 保留字編號
int8 ODmode[3]; // 操作數形式 有三個操作數
int8u OPobj; // 操作碼目標碼,十六進制8位數
int8 act1; // 動作1
int8 act2; // 動作2
int8u len; // 該指令長度
OPset* next;
}; // end OPset
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
struct ITset
{ int32u key; // 關鍵碼
int8u OPobj; // 操作碼目標碼,十六進制8位數
int8 act1; // 動作1
int8 act2; // 動作2
int8u len; // 該指令長度
ITset* next;
}; // end ITset
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
#define not3bit(x) ((x)&~0x07)
#define not4bit(x) ((x)&~0x0f)
#define not7bit(x) ((x)&~0x7f)
#define not8bit(x) ((x)&~0xff)
#define not11bit(x) ((x)&~0x07ff)
#define not16bit(x) ((x)&~0xffff)
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
void FatalErr(char* msg = "\nFatal error.\n");
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// 獲取不帶后綴名的文件名, 輸出Pname返回。
//---------------------------------------------------------------------------
void FetchPname(const char* name, Jstring &Pname);
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// 判斷token是否為運算符,true=是,false=否。
//---------------------------------------------------------------------------
bool IsOPTR(int16u token);
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// 比較兩個運算符的優先權。返回'<', '=', '>'。
//---------------------------------------------------------------------------
#define AlessB '<'
#define AequtB '='
#define AlargB '>'
//---------------------------------------------------------------------------
char OPsuperior(int16u t1, int16u t2);
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// p不能為空.
// 返回以p開頭的字串中的第一個字符(包括轉移字符)的ASCII碼.
// 例如: "boy and girls" -> 'b'; "!"" -> '"';
//---------------------------------------------------------------------------
inline char CharStrToint8(const char* p)
{ return (*p != '!') ? (*p) : p[1];
// 如果是空字串(*p==""),返回NULL.一般情況下,返回ASCII碼.
// If the first char is '!', 原樣輸出
} // end CharStrToint8
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
#define IsInvisibleChar(c) ( (c)<=' ' || (c)>'~' )
//---------------------------------------------------------------------------
#define IsVisibleChar(c) ( (c)>' ' && (c)<='~' )
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// 把p 指針移至一個可見符上,或者行末。
// 注意,p不能是空(即p!=NULL)。p帶值返回。
// 例如: [ \t abc \n] [ \t abc \n]
// ^ --> ^
//---------------------------------------------------------------------------
#define MovePoint(p) \
{ while(*(p) && IsInvisibleChar(*(p)) ) {++(p);} }
//---------------------------------------------------------------------------
// 注意,p不能是空.(即p!=NULL)
// 把p 指針移至一個可見符上,或者行末。
//---------------------------------------------------------------------------
//void MovePoint(const char* &p)
//{ while( *p && ( *p<=' ' || *p>'~' ) ) // 當p不是行末,又不是可見符時,p前移
// { ++p; } // end while
// // Now, p指向文本行中的第一個可見符,或者行末
//} // end MovePoint
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// 以可見符開頭,中間夾有字母或數字或'?'、'_'的字符串叫做單詞和數。
// 輸入一個字符串p。 ( p!= NULL !! ) 重要!
// 如果是單詞和數開頭,返回一個指向串中第一個單詞和數的指針。
// length返回單詞長度, behind指向單詞后一個字符。
// 不是單詞開頭,則返回NULL。len=0,behind指向文本行中的第一個可見符或者行末。
// exsample: [ Hello, how? ]
// ^ ^ ^
// p ret behind len=5
//---------------------------------------------------------------------------
const char* GetNumWord(const char* p, int16u &len, const char* &behind);
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
class HexcharMap // 字符映射表(從數值到ASCII碼轉換)
{ public:
static const char s[17]; // "0123456789ABCDEF";
}; // end HexcharMap
//---------------------------------------------------------------------------
// 從數值到字符的轉換。(輸入只取低4位。)
// 0~9 -> '0'~'9', A~H -> 'A'~'H'
//---------------------------------------------------------------------------
inline int8u v2char(int8u v)
{ v &= 0x0f; // 截去高4位,留下低4位。
return HexcharMap::s[v];
} // end v2char
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// xxxx -> "xxxx" 使用了快速轉換。
//---------------------------------------------------------------------------
const char* const Int16uToStr(int16u val);
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Error defination
//---------------------------------------------------------------------------
const ERR LabelUnDefErr = 3;
const ERR LabelDefNullErr = 4;
const ERR VarDefNullErr = 5;
const ERR ParaNameDefErr = 6;
const ERR UndefWordErr = 7;
const ERR EQUDefNullErr = 8;
const ERR SETDefNullErr = 9;
const ERR BITDefNullErr = 10;
const ERR InstNeededErr = 11;
const ERR ArguInsufErr = 12;
const ERR ArguExcevErr = 13;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -