commit 9101eeefa034836f99a982a8bdeda50775066933 Author: paladin Date: Tue May 19 12:35:23 2026 +0100 Sync diff --git a/src/examples/test.nel b/src/examples/test.nel new file mode 100644 index 0000000..4413394 --- /dev/null +++ b/src/examples/test.nel @@ -0,0 +1,11 @@ +/* +@native @inline +@expr(say (&a: String) (b: i32) times) +fn say_something(&a: String, b: i32) -> Pack { + for index in 0..b { + a += a + } + return {a,b} +} +*/ +println("where the huzz") \ No newline at end of file diff --git a/src/lang.rs b/src/lang.rs new file mode 100644 index 0000000..375aa7e --- /dev/null +++ b/src/lang.rs @@ -0,0 +1,103 @@ +struct Type { + name: String, + params: Vec, +} +struct Decl { + name: String, + typed: Option, + default: Option, +} +struct Param { + borrow: bool, + decl: Decl, +} +struct Call { + name: String, + params: Vec, +} +struct StructEntry { + name: Option, + value: Expr +} +struct FuncEntry { + name: Option, + value: Expr, + borrow: bool, +} +struct Class { + name: String, + entries: Vec, + methods: Vec, +} +struct Block(Vec); +struct Function { + annotations: Vec, + name: String, + params: Vec, + result: Type, +} +enum Overloaded { + Plus, + Get, + Set, + GetIndex, + SetIndex, +} +enum Annotation { + Inline, + Native, + Overload(Overloaded), + Expr(String), +} +enum Statement { + DeclLet(Decl), + DeclVar(Decl), + Assignment { + name: String, + expr: Expr, + }, + Call(Call), + Return(Expr), + Block(Block), + While(Expr,Box), + Loop(Box), + Function(Function), + Break, +} +enum Expr { + Paren(Box), + Call(Call), + Add { + left: Box, + right: Box, + }, + String(String), + Number(String), +} + +enum TopLevel { + Class(Class), + Statement(Statement) +} +struct Program(Vec); +struct ParseError(String); +struct Reader(String); +impl Reader { + +} +trait Parsed { + fn enter(reader: &mut Reader) -> ; + fn exit(reader: &mut Reader) -> Result<(), ParseError>; +} +impl Parsed for TopLevel { + +} +impl Parsed for Statement { + +} +impl Parsed for Expr { + +} +fn parse(source: String) -> Result { + Ok(Program(Vec::new())) +} diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..e8b1c3d --- /dev/null +++ b/src/main.rs @@ -0,0 +1,5 @@ +use game::run; + +fn main() { + run().unwrap(); +} \ No newline at end of file diff --git a/src/shader.wgsl b/src/shader.wgsl new file mode 100644 index 0000000..f5a0eae --- /dev/null +++ b/src/shader.wgsl @@ -0,0 +1,19 @@ +struct VertexOutput { + @builtin(position) clip_position: vec4, +}; + +@vertex +fn vs_main( + @builtin(vertex_index) in_vertex_index: u32, +) -> VertexOutput { + var out: VertexOutput; + let x = f32(1 - i32(in_vertex_index)) * 0.5; + let y = f32(i32(in_vertex_index & 1u) * 2 - 1) * 0.5; + out.clip_position = vec4(x, y, 0.0, 1.0); + return out; +} + +@fragment +fn fs_main(in: VertexOutput) -> @location(0) vec4 { + return vec4(0.3, 0.2, 0.1, 1.0); +} \ No newline at end of file diff --git a/src/shader2.wgsl b/src/shader2.wgsl new file mode 100644 index 0000000..bd92243 --- /dev/null +++ b/src/shader2.wgsl @@ -0,0 +1,21 @@ +struct VertexOutput { + @builtin(position) clip_position: vec4, + @location(0) color: vec4 +}; + +@vertex +fn vs_main( + @builtin(vertex_index) in_vertex_index: u32, +) -> VertexOutput { + var out: VertexOutput; + let x = f32(1 - i32(in_vertex_index)) * 0.5; + let y = f32(i32(in_vertex_index & 1u) * 2 - 1) * 0.5; + out.clip_position = vec4(x, y, 0.0, 1.0); + out.color = vec4(0.3,x,y,1.0); + return out; +} + +@fragment +fn fs_main(@location(0) col: vec4) -> @location(0) vec4 { + return col; +} \ No newline at end of file