From 46a169b88a4a67a472d02ac5f64736d0696e7e29 Mon Sep 17 00:00:00 2001 From: PuqiAR Date: Sun, 21 Dec 2025 23:23:10 +0800 Subject: [PATCH] README --- README.md | 65 +++++++++++++++++++++++++++++++++++++++++++++ README_ZH-CN.md | 62 ++++++++++++++++++++++++++++++++++++++++++ include/fassert.hpp | 3 --- test.fig | 6 +++-- 4 files changed, 131 insertions(+), 5 deletions(-) create mode 100644 README.md create mode 100644 README_ZH-CN.md delete mode 100644 include/fassert.hpp diff --git a/README.md b/README.md new file mode 100644 index 0000000..6952c7e --- /dev/null +++ b/README.md @@ -0,0 +1,65 @@ +# Fig Language - A Modern Scripting Language + +[简体中文](README_ZH-CN.md "Chinese version") + +**Fig** is a statically-typed, expression-oriented programming language designed for clarity, safety, and modern development practices. With features inspired by Go, Rust, and JavaScript, Fig aims to provide a productive development experience while maintaining strong type safety. + +## Features + +### 🚀 Core Language Features +- **Static typing with type inference** - Strong typing with minimal annotations +- **Modern control flow** - Full `for` loop support with proper scoping +- **First-class functions** - Lambda expressions and closures +- **Rich data structures** - Structs, lists, maps, and tuples +- **Memory safety** - No null pointer exceptions, automatic memory management + +### 🔧 Technical Highlights +- **Three-level scoping for loops** - Proper variable isolation in iterations +- **Smart semicolon handling** - Flexible statement termination with RAII guards +- **Comprehensive error handling** - Detailed error messages with source locations +- **Clean C++ implementation** - Modern C++23 with RAII and smart pointers + +### 📁 Project Structure + Fig/ + ├── src/ + │ ├── lexer.cpp # Lexical analysis + │ ├── parser.cpp # Syntax analysis + │ ├── evaluator.cpp # Interpreter/execution engine + │ └── value.cpp # Type system implementation + ├── include/ + │ ├── argparse + │ ├── magic_enum + │ ├── Ast # Abstract syntax tree definitions + │ ├── value.hpp # Type system header + │ ├── Value/ # Type system definitions + │ ├── ... + │ ├── AstPrinter.hpp # Ast printer + │ ├── context(_forward).hpp # Environment/Context system + │ ├── core.hpp # Core informations + │ ├── error.hpp # Exception system + │ ├── errorLog.hpp # Colored-Print error log + │ ├── fig_string.hpp # Fig UTF-8 string + │ ├── module.hpp # Package/Module system + │ ├── utils.hpp + │ ├── token.hpp # Token definitions + │ ├── lexer.hpp # Lexical analysis + │ ├── parser.hpp # Syntax analysis and AST + │ ├── evaluator.hpp # Interpreter and Control flows + │ ├── warning.hpp # STD-Warnings + ├── ExampleCodes/ # Sample programs + ├── .clang-format # Clang format styles + ├── test.fig # Test file (dev) + ├── LICENSE # Fig project license + ├── xmake.lua # XMake configurations + └── Logo/ # Fig's Logo + +## Language Philosophy + Fig is designed around several core principles: + + Clarity over cleverness - Code should be readable first + + Safety by default - Prevent common errors at compile time + + Modern ergonomics - Developer experience matters + + Gradual learning - Simple to start, powerful when needed \ No newline at end of file diff --git a/README_ZH-CN.md b/README_ZH-CN.md new file mode 100644 index 0000000..c6091fa --- /dev/null +++ b/README_ZH-CN.md @@ -0,0 +1,62 @@ +# Fig 语言 - 现代脚本语言 + +[English](README.md "英文版本") + +**Fig** 是一种静态类型、面向表达式的编程语言,专为清晰性、安全性和现代开发实践而设计。Fig 融合了 Go、Rust 和 JavaScript 的灵感,旨在提供高效的开发体验,同时保持强大的类型安全。 + +## 特性 + +### 🚀 核心语言特性 +- **静态类型与类型推断** - 强类型系统,最少类型注解 +- **现代控制流** - 完整的 `for` 循环支持,正确的作用域管理 +- **一等公民函数** - Lambda 表达式和闭包 +- **丰富的数据结构** - 结构体、列表、映射和元组 +- **内存安全** - 无空指针异常,自动内存管理 + +### 🔧 技术亮点 +- **三级循环作用域** - 迭代中正确的变量隔离 +- **智能分号处理** - 使用 RAII 守卫的灵活语句终止 +- **全面的错误处理** - 带有源码位置的详细错误信息 +- **干净的 C++ 实现** - 现代 C++23,使用 RAII 和智能指针 + +### 📁 项目结构 + Fig/ + ├── src/ + │ ├── lexer.cpp # 词法分析 + │ ├── parser.cpp # 语法分析 + │ ├── evaluator.cpp # 解释器/执行引擎 + │ └── value.cpp # 类型系统实现 + ├── include/ + │ ├── argparse + │ ├── magic_enum + │ ├── Ast # 抽象语法树定义 + │ ├── value.hpp # 类型系统头文件 + │ ├── Value/ # 类型系统定义 + │ │ ├── ... + │ ├── AstPrinter.hpp # AST 打印器 + │ ├── context(_forward).hpp # 环境/上下文系统 + │ ├── core.hpp # 核心信息 + │ ├── error.hpp # 异常系统 + │ ├── errorLog.hpp # 彩色打印错误日志 + │ ├── fig_string.hpp # Fig UTF-8 字符串 + │ ├── module.hpp # 包/模块系统 + │ ├── utils.hpp + │ ├── token.hpp # Token 定义 + │ ├── lexer.hpp # 词法分析 + │ ├── parser.hpp # 语法分析和 AST + │ ├── evaluator.hpp # 解释器和控制流 + │ ├── warning.hpp # 标准警告 + ├── ExampleCodes/ # 示例程序 + ├── .clang-format # Clang 格式化风格 + ├── test.fig # 测试文件(开发用) + ├── LICENSE # Fig 项目许可证 + ├── xmake.lua # XMake 配置 + └── Logo/ # Fig 的 Logo + +## 语言设计哲学 +Fig 围绕几个核心原则设计: + +1. **清晰优于巧妙** - 代码首先应该可读 +2. **默认为安全** - 在编译时防止常见错误 +3. **现代人机工程学** - 开发者体验很重要 +4. **渐进式学习** - 入门简单,需要时功能强大 \ No newline at end of file diff --git a/include/fassert.hpp b/include/fassert.hpp deleted file mode 100644 index 376d4f9..0000000 --- a/include/fassert.hpp +++ /dev/null @@ -1,3 +0,0 @@ -#pragma once - -#define fassert(exp,msg) (if(!exp) throw msg;) \ No newline at end of file diff --git a/test.fig b/test.fig index b6b4e4b..f5748aa 100644 --- a/test.fig +++ b/test.fig @@ -1,4 +1,6 @@ -for (var i=0;i < 10;i = i + 1) +const println := __fstdout_println; + +for var i=0;i<10;i=i+1 { - __fstdout_println(i); + println("Loop ", i); } \ No newline at end of file