Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,23 @@ A general-purpose system programming language and compiler, designed to build hi
- Lightweight, concise, and consistent syntax design, easy to master and get started quickly
- Strong type system, static analysis and compilation, memory safety, exception handling, making it easy to write secure and reliable software
- Built-in concurrency primitives: go/future/channel/select
- Comprehensive type system supporting generics, enum, tagged union, interface, nullable(?), errable(!)
- Compiles directly to machine code for the target platform, does not rely on LLVM, and supports cross-compilation.
- Simple deployment, efficient compilation, static linking based on musl libc with good cross-platform characteristics
- Comprehensive type system supporting generics, union types, interfaces, nullable(?), errable(!)
- High-performance C FFI implementation with zero-overhead calls to C standard library functions
- High-performance GC implementation with very short STW (Stop The World)
- High-performance memory allocator implementation, referencing tcmalloc
- High-performance shared-stack coroutine implementation, capable of millions of coroutine switches per second
- High-performance IO based on libuv implementation
- High-performance runtime and compiler based on pure C implementation
- Built-in data structures vec/map/set/tup and common standard library implementations
- Function calls follow system ABI, built-in libc, c std functions are called without performance loss.
- Built-in data structures vec/string/map/set/tup and common standard library implementations
- Test as a first-class citizen, write test blocks directly in source files
- Centralized package management system npkg
- Editor LSP support

## Overview

The nature programming language has reached an early usable version, with a basically stable syntax API that will not change significantly before version 1.0. Future versions will add some necessary and commonly used syntax features such as enum, ternary operators, struct labels, etc.

Key features to be completed include controllable memory allocator, LLM coding adaptation, DSL test framework, GUI adaptation, and WASM3.0 adaptation.
The nature programming language has reached an early usable version, and its core syntax features are now in place. Key features still to be completed include unsafe runtime mode, LLM coding adaptation, C target adaptation, and WASM3.0 target adaptation.

The current version supports compilation for the following target architectures: linux_amd64, linux_arm64, linux_riscv64, darwin_amd64, darwin_arm64.

Expand Down
12 changes: 5 additions & 7 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,30 @@
- 轻量、简洁、一致性的语法设计,轻松掌握并快速上手使用
- 强类型、静态分析与编译、内存安全、异常处理,轻松编写安全可靠的软件
- 内置并发原语 go/future/channel/select
- 完善的类型系统,支持 generics、enum、tagged union、interface、nullable(?)、errable(!)
- 直接编译为目标平台的机器码,不依赖 LLVM,并支持交叉编译
- 部署简单,高效编译,基于 musl libc 进行静态链接,具备良好的跨平台特性
- 完善的类型系统,支持泛型、联合类型、interface、nullable(?)、errable(!)
- 高性能 C FFI 实现,无性能损耗调用 C 标准库函数
- 高性能 GC 实现,具有非常短暂的 STW (Stop The World)
- 高性能内存分配器实现,参考 tcmalloc
- 高性能共享栈协程实现,每秒能够进行数百万次的协程切换
- 基于 libuv 实现的高性能 IO
- 纯 C 实现的高性能 runtime 和编译器
- 内置数据结构 vec/map/set/tup 和常用标准库实现
- 函数调用遵守 system ABI,内置 libc,无性能损耗调用 c 标准库函数
- 内置数据结构 vec/string/map/set/tup 和常用标准库实现
- test 作为一等公民,直接在源码文件中编写测试块
- 集中式包管理系统 npkg
- 编辑器 lsp 支持

## 概况

nature 编程语言已经达到早期可用版本,语法 API 基本稳定,在 1.0 版本之前不会有大幅的变化,后续版本会添加一些必要的语法,如 enum,三元运算符,struct label 等。

待完成的关键特性有可控内存分配器,LLM 编码适配,DSL 测试框架,GUI 适配,WASM3.0 适配。
nature 编程语言已经达到早期可用版本,核心语法功能以添加完成。待完成的关键特性有 unsafe 运行模式,LLM 编码适配,C target 适配,WASM3.0 target 适配。

当前版本编译目标架构包含 linux_amd64、linux_arm64、linux_riscv64、darwin_amd64、darwin_arm64。

nature 包含一组测试用例和标准库用来测试基本功能和语法的可用性,包含一组中小型项目测试整体可用性,还未经过大型的项目测试。

官网 https://nature-lang.cn


## 安装

从 [releases](https://github.com/nature-lang/nature/releases) 中下载并解压 nature 安装包(注意权限是否正确)。将解压后的 nature 文件夹移动到 `/usr/local/` 下,并将 `/usr/local/nature/bin` 目录加入到系统环境变量。
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.7.3
v0.7.4
9 changes: 3 additions & 6 deletions nls/src/analyzer/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,10 @@ impl Type {
err: false,
};

if Self::is_impl_builtin_type(&kind) {
if Self::is_origin_type(&kind) {
t.ident = kind.to_string();
t.ident_kind = TypeIdentKind::Builtin;
t.args = Vec::new();
}

return t;
Expand Down Expand Up @@ -635,17 +636,13 @@ pub struct TypeFn {
#[repr(u8)]
pub enum ReductionStatus {
Undo = 1,
Doing = 2,
Doing2 = 3,
Done = 4,
Done = 2,
}

impl Display for ReductionStatus {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
ReductionStatus::Undo => write!(f, "undo"),
ReductionStatus::Doing => write!(f, "doing"),
ReductionStatus::Doing2 => write!(f, "doing2"),
ReductionStatus::Done => write!(f, "done"),
}
}
Expand Down
9 changes: 8 additions & 1 deletion nls/src/analyzer/semantic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -669,12 +669,19 @@ impl<'a> Semantic<'a> {
let symbol_name = fndef.symbol_name.clone();

if fndef.impl_type.kind.is_exist() {
let mut impl_type_ident = fndef.impl_type.ident.clone();

if Type::is_impl_builtin_type(&fndef.impl_type.kind) {
impl_type_ident = fndef.impl_type.kind.to_string();
}

// 非 builtin type 则进行 resolve type 查找
if !Type::is_impl_builtin_type(&fndef.impl_type.kind) {
// resolve global ident
if let Some(symbol_id) = self.resolve_typedef(&mut fndef.impl_type.ident) {
// ident maybe change
fndef.impl_type.symbol_id = symbol_id;
impl_type_ident = fndef.impl_type.ident.clone();

// 自定义泛型 impl type 必须显式给出类型参数(仅检查 impl_type.args)
if let Some(symbol) = self.symbol_table.get_symbol(symbol_id) {
Expand Down Expand Up @@ -704,7 +711,7 @@ impl<'a> Semantic<'a> {
}
}

fndef.symbol_name = format_impl_ident(fndef.impl_type.ident.clone(), symbol_name);
fndef.symbol_name = format_impl_ident(impl_type_ident, symbol_name);

// register to global symbol table
match self.symbol_table.define_symbol_in_scope(
Expand Down
11 changes: 1 addition & 10 deletions nls/src/analyzer/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3212,10 +3212,7 @@ impl<'a> Syntax {
t
} else if (first_token.token_type == TokenType::Ident) && self.ident_is_builtin_type(first_token.clone()) {
if self.next_is(1, TokenType::LeftAngle) {
let mut t = self.parser_single_type()?;
t.ident = first_token.literal.clone();
t.ident_kind = TypeIdentKind::Builtin;
t
self.parser_single_type()?
} else {
self.must(TokenType::Ident)?;
let mut t = Type::unknown();
Expand All @@ -3226,9 +3223,6 @@ impl<'a> Syntax {
"tup" => TypeKind::Tuple(Vec::new(), 0),
_ => TypeKind::Ident,
};
t.ident = first_token.literal.clone();
t.ident_kind = TypeIdentKind::Builtin;
t.args = Vec::new();
t.start = first_token.start;
t.end = first_token.end;
t
Expand All @@ -3237,9 +3231,6 @@ impl<'a> Syntax {
self.must(TokenType::Chan)?;
let mut t = Type::unknown();
t.kind = TypeKind::Chan(Box::new(Type::unknown()));
t.ident = "chan".to_string();
t.ident_kind = TypeIdentKind::Builtin;
t.args = Vec::new();
t.start = first_token.start;
t.end = first_token.end;
t
Expand Down
Loading
Loading