This commit is contained in:
Shautvast 2025-10-27 20:51:13 +01:00
parent 84835da814
commit 3762b950b7
2 changed files with 38 additions and 23 deletions

View file

@ -1,9 +1,12 @@
# crud-lang # crud-lang
_This is now in first-draft phase. Meaning, I just had the idea and I am jotting down very preliminary design decisions._ ## What is this?
- an experimental language for CRUD applications (backend only though, I think) - an experimental language for CRUD applications (backend only though, I think)
- Enterprise as a first-class citizen - Enterprise as a first-class citizen
- built in types for dates and uuid for example
- collection literals
- ease of use for CRUD operations, like automatic mapping from sql rows to json
- a simple, yet powerful language
- urls are made up of directories and filenames - urls are made up of directories and filenames
- a controller sourcefile is a file with the .ctl extension - a controller sourcefile is a file with the .ctl extension
- likewise: - likewise:
@ -16,6 +19,7 @@ _This is now in first-draft phase. Meaning, I just had the idea and I am jotting
- there is a strict calling hierarchy. A service can not call a controller. It can only go 'down'. - there is a strict calling hierarchy. A service can not call a controller. It can only go 'down'.
- Services can not call other services, because that is the recipe for spaghetti. Refactor your logic, abstract and put lower level code in utilities. - Services can not call other services, because that is the recipe for spaghetti. Refactor your logic, abstract and put lower level code in utilities.
- Utilities are allowed to call other utilities. OMG, spaghetti after all! TBD - Utilities are allowed to call other utilities. OMG, spaghetti after all! TBD
- Automatic memory management using an arena per call
- It is an interpreter written in rust. OMG! - It is an interpreter written in rust. OMG!
- And it has everything I like in other languages - And it has everything I like in other languages
@ -28,6 +32,7 @@ _This is now in first-draft phase. Meaning, I just had the idea and I am jotting
- nice iterators. - nice iterators.
- First class functions? Maybe... - First class functions? Maybe...
- automatic mapping from database to object to json - automatic mapping from database to object to json
- indenting like python
**types** **types**
@ -35,7 +40,7 @@ _This is now in first-draft phase. Meaning, I just had the idea and I am jotting
- u64, i64 - u64, i64
- f32, f64, - f32, f64,
- string, bool, char - string, bool, char
- struct enum - struct, enum
- date - date
**question** **question**
@ -44,6 +49,34 @@ _This is now in first-draft phase. Meaning, I just had the idea and I am jotting
- middleware, implement later - middleware, implement later
- JWT tokens, I guess - JWT tokens, I guess
**the example im /src: ** **the example in /src: **
- a very simple api that listens to GET /api/customers{:id} and returns a customer from the database - a very simple api that listens to GET /api/customers{:id} and returns a customer from the database
## Design
* heavily inspired by Crafting Interpreters
* language influences from rust and python
* compiler first creates an AST and then compiles to bytecode (no file format yet)
* uses a stack-based virtual machine
## status:
* compiler and runtime are still limited but working
* supports:
* basic types:
* 32/64 bit integers, signed and unsigned
* 32/64 bit floats
* strings
* bools
* chars
* type checking and type inference (although it needs more testing)
* arithmetic expressions
* function declaration and calling
* indenting like python (for now just 1 level, but both tabs or double spaces)
* strict typing like in rust (no implicit numeric conversions)
* basic set of operators, including logical and/or and bitwise operations
## What's next?
- collection types: list and map
- object/struct types
- control flow
- tests

View file

@ -9,7 +9,7 @@ fn main() -> anyhow::Result<()> {
let tokens = scan( let tokens = scan(
r#" r#"
fn main(a: string) -> u32: fn main(a: string) -> u32:
a + 42 a + 42
let text = "hello " let text = "hello "
main(text)"#, main(text)"#,
); );
@ -26,23 +26,5 @@ main(text)"#,
} }
} }
// println!("{}",expression.infer_type());
// let chunk = crudlang::compiler::compile(
// r#"let a ="hello " + 42"#,
// );
// match chunk {
// Err(e) => {
// println!("{}", e);
// return Ok(());
// }
// Ok(chunk) => {
// chunk.disassemble();
//
// let result = crudlang::vm::interpret(chunk)?;
// println!("{}", result);
// }
// }
Ok(()) Ok(())
} }