From da1a8e04de503917b94f1a1da574616f546e2502 Mon Sep 17 00:00:00 2001 From: PuqiAR Date: Wed, 4 Feb 2026 19:12:18 +0800 Subject: [PATCH] =?UTF-8?q?v0.4.3-alpha=20[Fix]=20=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E8=B0=83=E7=94=A8=E6=97=B6=E5=8F=82=E6=95=B0=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E6=B1=82=E5=80=BC=E4=BD=BF=E7=94=A8=E9=94=99=E8=AF=AF=E4=BD=9C?= =?UTF-8?q?=E7=94=A8=E5=9F=9F=E7=9A=84=E9=97=AE=E9=A2=98=20[Fix]=20?= =?UTF-8?q?=E7=BB=93=E6=9E=84=E4=BD=93=E5=AE=9A=E4=B9=89=E4=B8=AD=E4=B8=8D?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E4=BD=BF=E7=94=A8=E8=87=AA=E8=BA=AB=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E7=9A=84bug=20[Fix]=20import=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E7=9A=84=E9=87=8D=E5=AE=9A=E4=B9=89bug=20[Impl]=20Parser?= =?UTF-8?q?=E7=9A=84precedence=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [Feat] 支持运算符重载, impl Operator for xxx {} 具体见 lang.fig中解释 [Feat] 新增标准库 std.test [Feat] 新增内置函数 type,接收一个参数,返回该参数的类型(value.type改名value._type) 推荐使用该函数替换 value._type [Feat] 新增转换运算符 as,转换失败时抛出TypeError,支持任意类型到String、部分类型到Int, Double等等转换 TypeError实现了Error interface,可被用户catch 推荐使用该feat或与std.value标准库结合 [Feat] 抛出实现Error interface的错误现在会有不一样的log [Feat] import增加cache(ast + source lines),但import一个module每次会得到不同对象而不是复用,请注意 --- ExampleCodes/FigFig/main.fig | 4 ++++ ExampleCodes/FigFig/token.fig | 31 +++++++++++++++++++++++++++++++ ExampleCodes/FigFig/tokenizer.fig | 20 ++++++++++++++++++++ src/Core/core.hpp | 2 +- 4 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 ExampleCodes/FigFig/main.fig create mode 100644 ExampleCodes/FigFig/token.fig create mode 100644 ExampleCodes/FigFig/tokenizer.fig diff --git a/ExampleCodes/FigFig/main.fig b/ExampleCodes/FigFig/main.fig new file mode 100644 index 0000000..e42d173 --- /dev/null +++ b/ExampleCodes/FigFig/main.fig @@ -0,0 +1,4 @@ +import std.io; + +import token {Token, TokenType}; +import tokenizer {Tokenizer}; diff --git a/ExampleCodes/FigFig/token.fig b/ExampleCodes/FigFig/token.fig new file mode 100644 index 0000000..a1d81b6 --- /dev/null +++ b/ExampleCodes/FigFig/token.fig @@ -0,0 +1,31 @@ +/* +Example code: FigFig + +Token.fig +Copyright (C) 2020-2026 PuqiAR + +*/ +struct _TokenTypes +{ + public EOF = -1; + public Identifier = 0; + + public StringLiteral = 1; + public NumberLiteral = 2; + public True = 3; + public False = 4; + public Null = 5; + + public Plus = 6; + public Minus = 7; + public Asterisk = 8; + public Slash = 9; +} + +public const TokenType := new _TokenTypes{}; + +public struct Token +{ + public literal: String = ""; + public type: Int = TokenType.EOF; +} \ No newline at end of file diff --git a/ExampleCodes/FigFig/tokenizer.fig b/ExampleCodes/FigFig/tokenizer.fig new file mode 100644 index 0000000..8d4ecb5 --- /dev/null +++ b/ExampleCodes/FigFig/tokenizer.fig @@ -0,0 +1,20 @@ +/* +Example code: FigFig + +Tokenizer.fig +Copyright (C) 2020-2026 PuqiAR + +*/ + +import token {Token, TokenType}; + +public struct Tokenizer +{ + src: String = ""; + + public func TokenizeAll() -> List + { + var output := []; + return output; + } +} \ No newline at end of file diff --git a/src/Core/core.hpp b/src/Core/core.hpp index a49dec2..2e07843 100644 --- a/src/Core/core.hpp +++ b/src/Core/core.hpp @@ -4,7 +4,7 @@ #include #include -#define __FCORE_VERSION "0.4.2-alpha" +#define __FCORE_VERSION "0.4.3-alpha" #if defined(_WIN32) #define __FCORE_PLATFORM "Windows"