📄 sp_const.java
字号:
import java.util.*;
/**
* 常量描述类
*
* @author 林玉东.烟台
* @version 1.0 11/01 2003
*/
public interface SP_Const
{
/**单词类型**/
//1.
int WT_NULL=0;
int WT_IntegerConst=1; //数字常数---用于标记表达式中的数字常数
int WT_FloatConst=2; //数字常数
int WT_StringConst=3; //字符串常数
int WT_Variable=4; //变量
int WT_SysFunction=5; //内部函数
int WT_UserFunction=6; //自定义函数
int WT_IntType=7; //数据类型-整形---用于标记类型
int WT_FloatType=8; //数据类型-
int WT_StringType=9; //数据类型-字符串
//2.界符
int WT_BECOME =60; // = 赋值
int WT_COMMA =61; // ,
int WT_SEMICOLON =62; // ;
int WT_COLON =63; // :
int WT_LPAREN =67; // (
int WT_RPAREN =68; // )
int WT_LBRACK =64; // [
int WT_RBRACK =65; // ]
//3.运算符
int WT_PLUS =80; // + --算术运算
int WT_MINUS =81; // -
int WT_TIMES =82; // *
int WT_DIVIDE =83; // /
int WT_MOD =84; // %
int WT_B_AND =100; // &
int WT_B_OR =101; // |
int WT_EQL =85; // == --关系运算
int WT_NEQ =86; // !=
int WT_GTR =87; // >
int WT_GEQ =88; // >=
int WT_LSS =89; // <
int WT_LEQ =90; // <=
int WT_R_AND =91; // && --逻辑运算
int WT_R_OR =92; // ||
int WT_R_NOT =93; // !
/**数据类型**/
public class WT_ReservedWord
{
public static boolean isReservedWord(String s)
{
return s.equals("int")||s.equals("float")||s.equals("string");
}
public static boolean isReservedWordType(int t)
{
return t==WT_IntType || t==WT_FloatType || t==WT_StringType;
}
public static int getType(String s)
{
if(s.equals("int"))
return WT_IntType;
else if(s.equals("float"))
return WT_FloatType;
else if(s.equals("string"))
return WT_StringType;
else
return WT_NULL;
}
public static int getDataType(int t)
{
if(t==WT_IntType)
return WT_IntegerConst;
else if(t==WT_FloatType)
return WT_FloatConst;
else if(t==WT_StringType)
return WT_StringConst;
else
return WT_NULL;
}
public static boolean isRelationType(int type)
{
return type>=WT_EQL && type <=WT_LEQ;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -