Skip to content

Commit

Permalink
Redesign the indexing compiler phase
Browse files Browse the repository at this point in the history
  • Loading branch information
purefunctor committed Feb 8, 2025
1 parent 156f227 commit 98c412d
Show file tree
Hide file tree
Showing 15 changed files with 2,305 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions crates/indexing/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[package]
name = "indexing"
version = "0.1.0"
edition = "2021"

[dependencies]
la-arena = "0.3.1"
paste = "1.0.15"
rowan = "0.16.1"
rustc-hash = "2.1.1"
smol_str = "0.3.2"
syntax = { version = "0.1.0", path = "../syntax" }

[dev-dependencies]
insta = "1.42.1"
lexing = { path = "../lexing" }
parsing = { path = "../parsing" }
test_each_file = "0.3.4"
3 changes: 3 additions & 0 deletions crates/indexing/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
println!("cargo:rerun-if-changed=tests/indexing")
}
25 changes: 25 additions & 0 deletions crates/indexing/src/algorithm.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
mod declaration;

use declaration::index_declaration;
use syntax::cst;

use crate::{Index, IndexError, Source};

#[derive(Debug, Default)]
pub(super) struct State {
pub(super) index: Index,
pub(super) source: Source,
pub(super) error: Vec<IndexError>,
}

pub(super) fn index_module(module: &cst::Module) -> State {
let mut state = State::default();

if let Some(statements) = module.statements() {
for declaration in statements.children() {
index_declaration(&mut state, &declaration);
}
}

state
}
Loading

0 comments on commit 98c412d

Please sign in to comment.