From 1e0741e6004309d8cd49c2f5d4bbf8c0eae2b8c2 Mon Sep 17 00:00:00 2001 From: Schrottkatze Date: Mon, 8 Jul 2024 20:20:45 +0200 Subject: [PATCH 1/2] lang: add credit to macro --- crates/lang/src/ast.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/lang/src/ast.rs b/crates/lang/src/ast.rs index 42d160c..d5838a2 100644 --- a/crates/lang/src/ast.rs +++ b/crates/lang/src/ast.rs @@ -1,6 +1,8 @@ use crate::lst_parser::syntax_kind::SyntaxKind::*; use crate::SyntaxNode; use rowan::Language; + +// Heavily modified version of https://github.com/rust-analyzer/rowan/blob/e2d2e93e16c5104b136d0bc738a0d48346922200/examples/s_expressions.rs#L250-L266 macro_rules! ast_nodes { ($($ast:ident, $kind:ident);+) => { $( From dc44244e7b88fa86ca471d2659c4e772d6c9a817 Mon Sep 17 00:00:00 2001 From: Schrottkatze Date: Mon, 8 Jul 2024 20:23:29 +0200 Subject: [PATCH 2/2] lang: work on some basics --- crates/lang/src/world.rs | 15 ++++++++++++++- crates/lang/src/world/files.rs | 3 ++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/crates/lang/src/world.rs b/crates/lang/src/world.rs index 2ce9997..7713422 100644 --- a/crates/lang/src/world.rs +++ b/crates/lang/src/world.rs @@ -1,5 +1,7 @@ use std::path::Path; +use self::files::{Files, OpenFileError}; + mod error; mod files; @@ -7,8 +9,19 @@ struct World; impl World { pub fn new(entry_point: &Path) -> Result { + let mut files = Files::default(); + let (entry_point_id, errors) = files.add_file(entry_point)?; + todo!() } } -enum WorldCreationError {} +enum WorldCreationError { + FailedToOpenEntryPoint(OpenFileError), +} + +impl From for WorldCreationError { + fn from(value: OpenFileError) -> Self { + Self::FailedToOpenEntryPoint(value) + } +} diff --git a/crates/lang/src/world/files.rs b/crates/lang/src/world/files.rs index 0c112ad..24053d7 100644 --- a/crates/lang/src/world/files.rs +++ b/crates/lang/src/world/files.rs @@ -15,7 +15,8 @@ use crate::{ world::{error::Error, files::source_file::SourceFile}, }; -struct Files { +#[derive(Default)] +pub struct Files { inner: Vec, path_to_id_map: HashMap, }