Some checks are pending
Build and Release / version-info (push) Waiting to run
Build and Release / build-linux (aarch64, debug) (push) Blocked by required conditions
Build and Release / build-linux (aarch64, release) (push) Blocked by required conditions
Build and Release / build-linux (x86_64, debug) (push) Blocked by required conditions
Build and Release / build-linux (x86_64, release) (push) Blocked by required conditions
Build and Release / build-windows (x64, debug) (push) Blocked by required conditions
Build and Release / build-windows (x64, release) (push) Blocked by required conditions
Build and Release / build-windows (x86, debug) (push) Blocked by required conditions
Build and Release / build-windows (x86, release) (push) Blocked by required conditions
Build and Release / build-macos (arm64, debug) (push) Blocked by required conditions
Build and Release / build-macos (arm64, release) (push) Blocked by required conditions
Build and Release / build-macos (x86_64, debug) (push) Blocked by required conditions
Build and Release / build-macos (x86_64, release) (push) Blocked by required conditions
Build and Release / build-cross-platform (android) (push) Blocked by required conditions
Build and Release / build-cross-platform (ios) (push) Blocked by required conditions
Build and Release / build-cross-platform (mingw) (push) Blocked by required conditions
Build and Release / create-release (push) Blocked by required conditions
88 lines
3.2 KiB
Markdown
88 lines
3.2 KiB
Markdown
# Fig 语言 - 现代脚本语言
|
||
|
||
仓库已从github迁移!不再更新,新的仓库: [Fig](https://git.fig-lang.cn/PuqiAR/Fig)
|
||
|
||
[English](README.md "英文版本")
|
||
|
||
**Fig** 是一种静态类型、面向表达式的编程语言,专为清晰性、安全性和现代开发实践而设计。Fig 融合了 Go、Rust 和 JavaScript 的灵感,旨在提供高效的开发体验,同时保持强大的类型安全。
|
||
|
||
## 特性
|
||
|
||
### 🚀 核心语言特性
|
||
- **静态类型与类型推断** - 强类型系统,最少类型注解
|
||
- **现代控制流** - 完整的 `for` 循环支持,正确的作用域管理
|
||
- **一等公民函数** - Lambda 表达式和闭包
|
||
- **丰富的数据结构** - 结构体、列表、映射和元组
|
||
- **内存安全** - 无空指针异常,自动内存管理
|
||
|
||
### 🔧 技术亮点
|
||
- **三级循环作用域** - 迭代中正确的变量隔离
|
||
- **智能分号处理** - 使用 RAII 守卫的灵活语句终止
|
||
- **全面的错误处理** - 带有源码位置的详细错误信息
|
||
- **干净的 C++ 实现** - 现代 C++23,使用 RAII 和智能指针
|
||
|
||
### 使用教程
|
||
1. 克隆存储库:
|
||
|
||
```bash
|
||
git clone https://github.com/PuqiAR/Fig.git
|
||
```
|
||
|
||
2. 切换到项目目录:
|
||
|
||
```bash
|
||
cd Fig
|
||
```
|
||
|
||
3. 构建项目:
|
||
|
||
```bash
|
||
xmake build Fig
|
||
```
|
||
|
||
4. 运行程序:
|
||
|
||
|
||
|
||
```bash
|
||
xmake run Fig [file]
|
||
```
|
||
将`[file]`替换为输入文件的路径。
|
||
|
||
### 📁 项目结构
|
||
.
|
||
├── ExampleCodes # 示例代码与性能测试样例
|
||
│ └── SpeedTest # 性能相关测试示例
|
||
├── LICENSE # 项目开源协议
|
||
├── Logo # 项目标识资源
|
||
├── README.md # 英文 README
|
||
├── README_ZH-CN.md # 中文 README
|
||
├── compile_flags.txt # C/C++ 编译器参数提示
|
||
├── fig-vscode # VSCode 插件项目
|
||
│ ├── node_modules # VSCode 插件依赖
|
||
│ ├── out # 构建产物
|
||
│ ├── src # VSCode 插件源码
|
||
│ └── syntaxes # 语法高亮定义
|
||
├── src # Fig 语言核心源码
|
||
│ ├── Ast # 抽象语法树节点
|
||
│ ├── Context # 运行上下文
|
||
│ ├── Core # 核心基础设施(字符串/UTF8 等)
|
||
│ ├── Error # 错误系统
|
||
│ ├── Evaluator # 解释执行器
|
||
│ ├── Lexer # 词法分析器
|
||
│ ├── Module # 模块与内置库
|
||
│ ├── Parser # 语法解析器
|
||
│ ├── Token # Token 定义
|
||
│ ├── Utils # 实用工具与第三方 header
|
||
│ └── Value # 运行时类型系统与值表示
|
||
├── test.fig # 测试脚本
|
||
└── xmake.lua # Xmake 构建脚本
|
||
|
||
|
||
## 语言设计哲学
|
||
Fig 围绕几个核心原则设计:
|
||
|
||
1. **清晰优于巧妙** - 代码首先应该可读
|
||
2. **默认为安全** - 在编译时防止常见错误
|
||
3. **现代人机工程学** - 开发者体验很重要
|
||
4. **渐进式学习** - 入门简单,需要时功能强大 |