增加数据类型
This commit is contained in:
parent
f970392389
commit
379d1adfc7
@ -32,6 +32,11 @@ public class SemanticAnalyzer {
|
||||
*/
|
||||
public static final Map<String, Type> BUILTIN_TYPES = Map.of(
|
||||
"int", BuiltinType.INT,
|
||||
"long", BuiltinType.LONG,
|
||||
"short", BuiltinType.SHORT,
|
||||
"byte", BuiltinType.BYTE,
|
||||
"float", BuiltinType.FLOAT,
|
||||
"double", BuiltinType.DOUBLE,
|
||||
"string", BuiltinType.STRING,
|
||||
"void", BuiltinType.VOID
|
||||
);
|
||||
|
||||
@ -1,31 +1,39 @@
|
||||
package org.jcnc.snow.compiler.semantic.type;
|
||||
|
||||
/**
|
||||
* 内置基础类型枚举:定义编译器中最基本的三种类型。
|
||||
* 内置基础类型枚举:定义编译器中常见的基础类型。
|
||||
* <p>
|
||||
* 枚举值:
|
||||
* <ul>
|
||||
* <li>{@link #INT} – 整数类型,也可用于表示布尔值(真/假);</li>
|
||||
* <li>{@link #INT} – 整数类型(32 位);</li>
|
||||
* <li>{@link #LONG} – 长整数类型(64 位);</li>
|
||||
* <li>{@link #SHORT} – 短整数类型(16 位);</li>
|
||||
* <li>{@link #BYTE} – 字节类型(8 位);</li>
|
||||
* <li>{@link #FLOAT} – 单精度浮点数;</li>
|
||||
* <li>{@link #DOUBLE} – 双精度浮点数;</li>
|
||||
* <li>{@link #STRING} – 字符串类型;</li>
|
||||
* <li>{@link #VOID} – 空类型,用于表示无返回值的函数。</li>
|
||||
* </ul>
|
||||
* <p>
|
||||
* 本枚举实现了 {@link Type} 接口,提供了基本的类型兼容性判断和友好的字符串表示方法。
|
||||
* 本枚举实现了 {@link Type} 接口,提供了基本的类型兼容性判断和
|
||||
* 友好的字符串表示方法。
|
||||
*/
|
||||
public enum BuiltinType implements Type {
|
||||
/**
|
||||
* 整数类型,也可用于表示布尔值(真假值)。
|
||||
*/
|
||||
/** 整数类型(32 位) */
|
||||
INT,
|
||||
|
||||
/**
|
||||
* 字符串类型。
|
||||
*/
|
||||
/** 长整数类型(64 位) */
|
||||
LONG,
|
||||
/** 短整数类型(16 位) */
|
||||
SHORT,
|
||||
/** 字节类型(8 位) */
|
||||
BYTE,
|
||||
/** 单精度浮点数 */
|
||||
FLOAT,
|
||||
/** 双精度浮点数 */
|
||||
DOUBLE,
|
||||
/** 字符串类型 */
|
||||
STRING,
|
||||
|
||||
/**
|
||||
* 空类型,通常用于无返回值的函数。
|
||||
*/
|
||||
/** 空类型,通常用于无返回值的函数 */
|
||||
VOID;
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user