syntax v2

introduce a new, more ergonomic syntax for haku
not all features are implemented just yet. still missing:

- custom tags (non-True/False)
- color literals
- lists
This commit is contained in:
りき萌 2024-08-27 20:43:14 +02:00
parent a3e5e8bd10
commit 2595bf0d82
21 changed files with 2844 additions and 1062 deletions

View file

@ -1,6 +1,6 @@
use alloc::vec::Vec;
use crate::system::ChunkId;
use crate::{compiler::ClosureSpec, system::ChunkId};
// TODO: Probably needs some pretty hardcore space optimization.
// Maybe when we have static typing.
@ -156,9 +156,25 @@ pub struct Closure {
pub start: BytecodeLoc,
pub name: FunctionName,
pub param_count: u8,
pub local_count: u8,
pub captures: Vec<Value>,
}
impl Closure {
pub fn chunk(chunk_id: ChunkId, spec: ClosureSpec) -> Self {
Self {
start: BytecodeLoc {
chunk_id,
offset: 0,
},
name: FunctionName::Anonymous,
param_count: 0,
local_count: spec.local_count,
captures: Vec::new(),
}
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct List {
pub elements: Vec<Value>,