From f870bbe3c752f50f1c12211a9582aa43ba7c4205 Mon Sep 17 00:00:00 2001 From: Alex Bethel Date: Wed, 10 Aug 2022 23:05:07 -0500 Subject: [PATCH] Rename the language to Drim --- README.md | 67 +++++++++++++-------------- axc/foo.axs | 49 -------------------- axc/src/lib.rs | 12 ----- {axc => drimc_rs}/Cargo.lock | 18 +++---- {axc => drimc_rs}/Cargo.toml | 2 +- drimc_rs/foo.drim | 51 ++++++++++++++++++++ {axc => drimc_rs}/src/ast2ir.rs | 0 {axc => drimc_rs}/src/backends/c.rs | 0 {axc => drimc_rs}/src/backends/mod.rs | 0 {axc => drimc_rs}/src/ir.rs | 0 drimc_rs/src/lib.rs | 13 ++++++ {axc => drimc_rs}/src/main.rs | 8 ++-- {axc => drimc_rs}/src/parser.rs | 8 ++-- {axc => drimc_rs}/src/syntax.rs | 4 +- {axc => drimc_rs}/src/typeck.rs | 0 drimc_rs/stdlib/std.axs | 3 ++ examples/{hello.axs => hello.drim} | 0 examples/{unwrap.axs => unwrap.drim} | 0 18 files changed, 118 insertions(+), 117 deletions(-) delete mode 100644 axc/foo.axs delete mode 100644 axc/src/lib.rs rename {axc => drimc_rs}/Cargo.lock (99%) rename {axc => drimc_rs}/Cargo.toml (93%) create mode 100644 drimc_rs/foo.drim rename {axc => drimc_rs}/src/ast2ir.rs (100%) rename {axc => drimc_rs}/src/backends/c.rs (100%) rename {axc => drimc_rs}/src/backends/mod.rs (100%) rename {axc => drimc_rs}/src/ir.rs (100%) create mode 100644 drimc_rs/src/lib.rs rename {axc => drimc_rs}/src/main.rs (98%) rename {axc => drimc_rs}/src/parser.rs (99%) rename {axc => drimc_rs}/src/syntax.rs (98%) rename {axc => drimc_rs}/src/typeck.rs (100%) create mode 100644 drimc_rs/stdlib/std.axs rename examples/{hello.axs => hello.drim} (100%) rename examples/{unwrap.axs => unwrap.drim} (100%) diff --git a/README.md b/README.md index 90c5751..b9b87dd 100644 --- a/README.md +++ b/README.md @@ -7,24 +7,20 @@ is formatted correctly! ~~abb --> -# AlexScript +# Drim -AlexScript is a programming language designed to have the very -high-level ergonomics and provable correctness of a purely functional -language, while maintaining speed using strictly-controlled, -deterministic memory management. The language is capable of compiling -to C (and possibly other languages in the future), allowing for -maximum portability without having to write a new backend for the -compiler for every possible target; also, the compiler and tooling -will eventually be rewritten in AlexScript to allow for maximum -portability. +Drim is a programming language designed to have the very high-level +ergonomics and provable correctness of a purely functional language, +while maintaining speed using strictly-controlled, deterministic +memory management. The language is capable of compiling to C (and +possibly other languages in the future), allowing for maximum +portability without having to write a new backend for the compiler for +every possible target; also, the compiler and tooling will eventually +be rewritten in Drim to allow for maximum portability. Syntactically, the language primarily resembles a mixture between standard ML and Rust; the language always ignores whitespace. -AlexScript is a misnomer; the language is not actually a scripting -language and will probably be renamed in the near future. - ## Example ``` @@ -55,33 +51,32 @@ Note that type annotations are always optional; here they're given for ## Tools This repository contains the following tools: -- `axc-rs`, the Stage-1 AlexScript compiler, written in Rust. This can - be used as a binary with a fairly standard compiler CLI, or as a +- `drimc-rs`, the Stage-1 Drim compiler, written in Rust. This can be + used as a binary with a fairly standard compiler CLI, or as a library for use in other Rust programs. The following tools do not exist yet, but are planned: -- `axc`, the main AlexScript compiler written in AlexScript. This - program supports a superset of the behavior of `axc-rs`, and exposes - a library that can be used by other AlexScript programs in addition - to a the compiler CLI. -- `axci`, the interactive AlexScript interpreter, a wrapper around - `axc`. -- `axcd`, the Language Server Protocol (LSP) server for AlexScript - code support in editors, supporting definition peeking and lookup, +- `drimc`, the main Drim compiler written in Drim. This program + supports a superset of the behavior of `drimc-rs`, and exposes a + library that can be used by other Drim programs in addition to a the + compiler CLI. +- `drim`, the interactive Drim interpreter, a wrapper around `drimc`. +- `drimd`, the Language Server Protocol (LSP) server for Drim code + support in editors, supporting definition peeking and lookup, renaming variables and modules, etc. -- `axfmt`, the standard formatter for AlexScript code; all AlexScript - code used in this repository must be formatted with `axfmt`, and its - use is recommended for other projects. -- `axdoc`, the documentation generator. -- `alexscript-mode`, an Emacs mode for editing AlexScript code, - supporting syntax highlighting, automatic indentation, some basic - keybindings for common tasks, Emacs-side LSP integration for - communicating with `acxd`, and a collection of `yasnippet` snippets - for inserting common AlexScript constructs. -- `alexscript-vsc`, Visual Studio Code plugins and tools for editing +- `drimfmt`, the standard formatter for Drim code; all Drim code used + in this repository must be formatted with `drimfmt`, and its use is + recommended for other projects. +- `drimdoc`, the documentation generator. +- `drim-mode`, an Emacs mode for editing Drim code, supporting syntax + highlighting, automatic indentation, some basic keybindings for + common tasks, Emacs-side LSP integration for communicating with + `drimd`, and a collection of `yasnippet` snippets for inserting + common Drim constructs. +- `drim-vsc`, Visual Studio Code plugins and tools for editing AlexScript code. -- `alexscript-vim`, tools and configuration files for optimizing Vim - and Neovim for editing AlexScript code. +- `drim-vim`, tools and configuration files for optimizing Vim + and Neovim for editing Drim code. ## Language features @@ -130,7 +125,7 @@ Some features the language will most likely have: ## Compilation -When invoked with no flags, AlexScript by default compiles source code +When invoked with no flags, Drim by default compiles source code directly to code that is valid C and C++, then calls the system C compiler to generate an object file, then calls the system linker to generate an executable file. diff --git a/axc/foo.axs b/axc/foo.axs deleted file mode 100644 index 76ae887..0000000 --- a/axc/foo.axs +++ /dev/null @@ -1,49 +0,0 @@ -// AlexScript test - -extern def core::intrinsic::negate_u32 : U32 -> U32; -extern def core::intrinsic::pow_u32 : U32 -> U32 -> U32; -extern def core::intrinsic::mul_u32 : U32 -> U32 -> U32; -extern def core::intrinsic::div_u32 : U32 -> U32 -> U32; -extern def core::intrinsic::mod_u32 : U32 -> U32 -> U32; -extern def core::intrinsic::plus_u32 : U32 -> U32 -> U32; -extern def core::intrinsic::minus_u32 : U32 -> U32 -> U32; -extern def core::intrinsic::equal_u32 : U32 -> U32 -> U32; -extern def core::intrinsic::notEqual_u32 : U32 -> U32 -> U32; -extern def core::intrinsic::lessThan_u32 : U32 -> U32 -> U32; -extern def core::intrinsic::lessThanEq_u32 : U32 -> U32 -> U32; -extern def core::intrinsic::greaterThan_u32 : U32 -> U32 -> U32; -extern def core::intrinsic::greaterThanEq_u32 : U32 -> U32 -> U32; -extern def core::intrinsic::and_u32 : U32 -> U32 -> U32; -extern def core::intrinsic::or_u32 : U32 -> U32 -> U32; - -extern data U32; - -class Group n { - def plus : n -> n -> n; - def zero : n; - def negate : n -> n; -} - -class Group n => Ring n { - def mul : n -> n -> n; - def one : n; -} - -instance Group U32 { - def plus = core::intrinsic::plus_u32; - def zero = 0; - def negate = core::intrinsic::negate_u32; -} - -instance Ring U32 { - def mul = core::intrinsics::mul_u32; - def one = 1; -} - -extern def print_u32 : U32 -> (); - -// Impurity expliot to chain together actions. -def progn (l: ()) (r: ()) : () = (); - -def main : () = - print_u32 (2 + 2); diff --git a/axc/src/lib.rs b/axc/src/lib.rs deleted file mode 100644 index 9cc8b66..0000000 --- a/axc/src/lib.rs +++ /dev/null @@ -1,12 +0,0 @@ -//! AlexScript compiler. -//! -//! AlexScript is a based programming language, for based people. - -#![deny(missing_docs)] - -pub mod ast2ir; -pub mod backends; -pub mod ir; -pub mod parser; -pub mod syntax; -pub mod typeck; diff --git a/axc/Cargo.lock b/drimc_rs/Cargo.lock similarity index 99% rename from axc/Cargo.lock rename to drimc_rs/Cargo.lock index 1f03237..88b97a6 100644 --- a/axc/Cargo.lock +++ b/drimc_rs/Cargo.lock @@ -28,15 +28,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" -[[package]] -name = "axc" -version = "0.1.0" -dependencies = [ - "chumsky", - "clap", - "num-bigint", -] - [[package]] name = "bitflags" version = "1.3.2" @@ -125,6 +116,15 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" +[[package]] +name = "drimc_rs" +version = "0.1.0" +dependencies = [ + "chumsky", + "clap", + "num-bigint", +] + [[package]] name = "getrandom" version = "0.2.7" diff --git a/axc/Cargo.toml b/drimc_rs/Cargo.toml similarity index 93% rename from axc/Cargo.toml rename to drimc_rs/Cargo.toml index 024b574..2c72204 100644 --- a/axc/Cargo.toml +++ b/drimc_rs/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "axc" +name = "drimc_rs" version = "0.1.0" edition = "2021" diff --git a/drimc_rs/foo.drim b/drimc_rs/foo.drim new file mode 100644 index 0000000..707f3c0 --- /dev/null +++ b/drimc_rs/foo.drim @@ -0,0 +1,51 @@ +// AlexScript test + +def extern core::intrinsic::negate_u32 : U32 -> U32; +def extern core::intrinsic::pow_u32 : U32 -> U32 -> U32; +def extern core::intrinsic::mul_u32 : U32 -> U32 -> U32; +def extern core::intrinsic::div_u32 : U32 -> U32 -> U32; +def extern core::intrinsic::mod_u32 : U32 -> U32 -> U32; +def extern core::intrinsic::plus_u32 : U32 -> U32 -> U32; +def extern core::intrinsic::minus_u32 : U32 -> U32 -> U32; +def extern core::intrinsic::equal_u32 : U32 -> U32 -> U32; +def extern core::intrinsic::notEqual_u32 : U32 -> U32 -> U32; +def extern core::intrinsic::lessThan_u32 : U32 -> U32 -> U32; +def extern core::intrinsic::lessThanEq_u32 : U32 -> U32 -> U32; +def extern core::intrinsic::greaterThan_u32 : U32 -> U32 -> U32; +def extern core::intrinsic::greaterThanEq_u32 : U32 -> U32 -> U32; +def extern core::intrinsic::and_u32 : U32 -> U32 -> U32; +def extern core::intrinsic::or_u32 : U32 -> U32 -> U32; + +data extern U32; + +class Group n { + def plus : n -> n -> n; + def zero : n; + def negate : n -> n; +} + +class Group n => Ring n { + def mul : n -> n -> n; + def one : n; +} + +instance Group U32 { + def plus = core::intrinsic::plus_u32; + def zero = 0; + def negate = core::intrinsic::negate_u32; +} + +instance Ring U32 { + def mul = core::intrinsics::mul_u32; + def one = 1; +} + +def extern print_u32 : U32 -> (); + +// Impurity expliot to chain together actions. +def progn (l: ()) (r: ()) : () = (); + +def main : () = + progn (print_u32 (2 + 2)) + (progn (print_u32 (3 * 3)) + (progn (print_u32 (4 ^ 4)))); diff --git a/axc/src/ast2ir.rs b/drimc_rs/src/ast2ir.rs similarity index 100% rename from axc/src/ast2ir.rs rename to drimc_rs/src/ast2ir.rs diff --git a/axc/src/backends/c.rs b/drimc_rs/src/backends/c.rs similarity index 100% rename from axc/src/backends/c.rs rename to drimc_rs/src/backends/c.rs diff --git a/axc/src/backends/mod.rs b/drimc_rs/src/backends/mod.rs similarity index 100% rename from axc/src/backends/mod.rs rename to drimc_rs/src/backends/mod.rs diff --git a/axc/src/ir.rs b/drimc_rs/src/ir.rs similarity index 100% rename from axc/src/ir.rs rename to drimc_rs/src/ir.rs diff --git a/drimc_rs/src/lib.rs b/drimc_rs/src/lib.rs new file mode 100644 index 0000000..18e659c --- /dev/null +++ b/drimc_rs/src/lib.rs @@ -0,0 +1,13 @@ +//! Drim compiler. +//! +//! Drim is a modern, purely-functional programming language with a powerful linear type system and +//! an emphasis on performance. + +#![deny(missing_docs)] + +pub mod ast2ir; +pub mod backends; +pub mod ir; +pub mod parser; +pub mod syntax; +pub mod typeck; diff --git a/axc/src/main.rs b/drimc_rs/src/main.rs similarity index 98% rename from axc/src/main.rs rename to drimc_rs/src/main.rs index 28b1e97..9ff0951 100644 --- a/axc/src/main.rs +++ b/drimc_rs/src/main.rs @@ -1,8 +1,8 @@ -//! AlexScript CLI. +//! Drim compiler CLI. use std::{error::Error, fmt::Display, fs::File, io::Write, process::exit, str::FromStr}; -use axc::{ +use drimc_rs::{ ast2ir::ast2ir, backends, parser::{parser, ParserError, ParserMeta}, @@ -225,7 +225,7 @@ impl FromStr for Target { } } -/// The AlexScript compiler. +/// The Drim compiler. #[derive(Parser, Debug)] #[clap(version = "0.1.0")] struct Args { @@ -286,7 +286,7 @@ fn main() { match main_e() { Ok(()) => (), Err(e) => { - eprintln!("axc fatal error: {}", e); + eprintln!("drimc-rs fatal error: {}", e); exit(1); } } diff --git a/axc/src/parser.rs b/drimc_rs/src/parser.rs similarity index 99% rename from axc/src/parser.rs rename to drimc_rs/src/parser.rs index b91ce00..d32ec52 100644 --- a/axc/src/parser.rs +++ b/drimc_rs/src/parser.rs @@ -1,4 +1,4 @@ -//! AlexScript parser. +//! Drim parser. use std::{error::Error, fmt::Display}; @@ -28,7 +28,7 @@ impl Display for ParserError { impl Error for ParserError {} -/// Information required to be able to parse AlexScript code, beyond the code itself. +/// Information required to be able to parse Drim code, beyond the code itself. pub struct ParserMeta { // This struct is just a total hacky workaround for the fact that chumsky isn't capable of // parsing a context-sensitive grammar. I don't intend on ever fixing this: the stage-1 compiler @@ -233,7 +233,7 @@ impl Default for ParserMeta { } } -/// The list of reserved words that cannot be used as identifiers in AlexScript. +/// The list of reserved words that cannot be used as identifiers in Drim. #[rustfmt::skip] // keep this on separate lines for sorting pub const RESERVED: &[&str] = &[ "_", @@ -248,7 +248,7 @@ pub const RESERVED: &[&str] = &[ "type", ]; -/// Parser for AlexScript code. +/// Parser for Drim code. pub fn parser<'a>(m: &'a ParserMeta) -> impl Parser> + 'a { whitespace_cmt().ignore_then( parse_statement(m) diff --git a/axc/src/syntax.rs b/drimc_rs/src/syntax.rs similarity index 98% rename from axc/src/syntax.rs rename to drimc_rs/src/syntax.rs index 0c0965d..9411a42 100644 --- a/axc/src/syntax.rs +++ b/drimc_rs/src/syntax.rs @@ -1,8 +1,8 @@ -//! Syntax tree for AlexScript code. +//! Syntax tree for Drim code. use num_bigint::BigUint; -/// A concrete syntax tree. This represents the full content of an AlexScript program, including all +/// A concrete syntax tree. This represents the full content of a Drim program, including all /// whitespace, comments, and tokens: the source code of the original program can be recovered /// completely using the syntax tree. #[derive(Clone, Debug)] diff --git a/axc/src/typeck.rs b/drimc_rs/src/typeck.rs similarity index 100% rename from axc/src/typeck.rs rename to drimc_rs/src/typeck.rs diff --git a/drimc_rs/stdlib/std.axs b/drimc_rs/stdlib/std.axs new file mode 100644 index 0000000..f86d033 --- /dev/null +++ b/drimc_rs/stdlib/std.axs @@ -0,0 +1,3 @@ +// Drim standard library. + +// Copyright (C) 2022 by Alexander Bethel. diff --git a/examples/hello.axs b/examples/hello.drim similarity index 100% rename from examples/hello.axs rename to examples/hello.drim diff --git a/examples/unwrap.axs b/examples/unwrap.drim similarity index 100% rename from examples/unwrap.axs rename to examples/unwrap.drim