Initial commit
This commit is contained in:
commit
0a9dc80583
13 changed files with 239 additions and 0 deletions
9
crates/parser/Cargo.toml
Normal file
9
crates/parser/Cargo.toml
Normal file
|
@ -0,0 +1,9 @@
|
|||
[package]
|
||||
name = "saja-parser"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
chumsky = "0.9.3"
|
||||
compact_str.workspace = true
|
||||
|
3
crates/parser/src/lib.rs
Normal file
3
crates/parser/src/lib.rs
Normal file
|
@ -0,0 +1,3 @@
|
|||
pub mod stmt;
|
||||
|
||||
pub mod types;
|
8
crates/parser/src/stmt.rs
Normal file
8
crates/parser/src/stmt.rs
Normal file
|
@ -0,0 +1,8 @@
|
|||
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub enum Stmt {
|
||||
BgLoad(bgload::BgLoad),
|
||||
SetImg(setimg::SetImg),
|
||||
}
|
||||
|
||||
pub mod bgload;
|
||||
pub mod setimg;
|
9
crates/parser/src/stmt/bgload.rs
Normal file
9
crates/parser/src/stmt/bgload.rs
Normal file
|
@ -0,0 +1,9 @@
|
|||
use compact_str::CompactString;
|
||||
|
||||
use crate::types::Fadetime;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub struct BgLoad {
|
||||
pub file: CompactString,
|
||||
pub fadetime: Option<Fadetime>,
|
||||
}
|
9
crates/parser/src/stmt/setimg.rs
Normal file
9
crates/parser/src/stmt/setimg.rs
Normal file
|
@ -0,0 +1,9 @@
|
|||
use compact_str::CompactString;
|
||||
|
||||
use crate::types::Position;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub struct SetImg {
|
||||
pub file: CompactString,
|
||||
pub position: Position,
|
||||
}
|
21
crates/parser/src/types.rs
Normal file
21
crates/parser/src/types.rs
Normal file
|
@ -0,0 +1,21 @@
|
|||
use std::num::NonZeroU16;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
|
||||
#[repr(transparent)]
|
||||
pub struct Fadetime(pub NonZeroU16);
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
|
||||
#[repr(transparent)]
|
||||
pub struct Coord(pub i16);
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub struct Position(pub Coord, pub Coord);
|
||||
|
||||
impl Position {
|
||||
pub const fn offset(self, Offset(dx, dy): Offset) -> Self {
|
||||
Self(Coord(self.0 .0 + dx.0), Coord(self.1 .0 + dy.0))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub struct Offset(pub Coord, pub Coord);
|
Loading…
Add table
Add a link
Reference in a new issue