Skip to content

feat: add multi file support, Implement parser context queue and external symbol registration#102

Merged
0xGeorgii merged 1 commit into
Inferara:mainfrom
Emmyt24:Emmyt24-branch
May 29, 2026
Merged

feat: add multi file support, Implement parser context queue and external symbol registration#102
0xGeorgii merged 1 commit into
Inferara:mainfrom
Emmyt24:Emmyt24-branch

Conversation

@Emmyt24

@Emmyt24 Emmyt24 commented Jan 22, 2026

Copy link
Copy Markdown
Contributor

resolves #66

@0xGeorgii 0xGeorgii requested a review from Copilot January 22, 2026 11:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements multi-file support for the compiler by introducing a parser context queue system and enabling external symbol registration across modules. The changes allow parsing multiple source files connected via mod declarations and properly registering their definitions in the symbol table.

Changes:

  • Added ParserContext with queue-based multi-file parsing
  • Extended symbol table to register external functions, constants, and modules
  • Modified code generation to traverse module definitions recursively

Reviewed changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
core/wasm-codegen/src/lib.rs Removed multi-file restriction and added recursive module compilation
core/type-checker/src/type_checker.rs Refactored type registration and inference to handle nested module definitions
core/type-checker/src/symbol_table.rs Extended external definition registration to support constants, external functions, and modules
core/inference/src/lib.rs Added parse_file entry point for multi-file projects
core/cli/src/parser.rs Updated CLI documentation to reflect multi-file support
core/cli/src/main.rs Changed to use parse_file instead of parse
core/ast/src/parser_context.rs Implemented queue-based parsing with module scanning and submodule resolution
core/ast/src/nodes_impl.rs Changed module body to use RefCell for delayed initialization
core/ast/src/nodes.rs Updated ModuleDefinition.body type to RefCell<Option<Vec<Definition>>>
core/ast/src/lib.rs Updated documentation to indicate ParserContext is no longer WIP
core/ast/src/builder.rs Added location base tracking and made several methods public for parser context

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread core/type-checker/src/type_checker.rs Outdated
}
}

fn infer_definitions(&mut self, definitions: &[Definition], ctx: &mut TypedContext, path: &[String]) {

Copilot AI Jan 22, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The path parameter is declared but never used in this function or passed to nested calls. Either use it for module path tracking or remove it if not needed.

Copilot uses AI. Check for mistakes.
Comment thread core/ast/src/parser_context.rs Outdated
.set_language(&tree_sitter_inference::language())
.map_err(|_| anyhow::anyhow!("Error loading Inference grammar"))?;
let mut builder = Builder::new();
let source_file_id = Builder::next_node_id();

Copilot AI Jan 22, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using Builder::next_node_id() outside of the Builder context is confusing. Consider using self.next_node_id() for consistency with how IDs are generated elsewhere in this context.

Suggested change
let source_file_id = Builder::next_node_id();
let source_file_id = builder.next_node_id();

Copilot uses AI. Check for mistakes.
Comment thread core/ast/src/parser_context.rs Outdated
LocationBase {
offset: offset as u32,
line: line.saturating_sub(1),
column: column.saturating_sub(1),

Copilot AI Jan 22, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The column is being decremented by 1, but on line 276 it's incremented by 1, and on line 1587 of builder.rs it's also incremented by 1. This could lead to off-by-one errors in column numbering. Verify the intended column indexing convention (0-based vs 1-based).

Copilot uses AI. Check for mistakes.
Comment thread core/ast/src/builder.rs Outdated
Comment on lines +1599 to +1604
if start_position.row == 0 {
start_column += self.location_base.column;
}
if end_position.row == 0 {
end_column += self.location_base.column;
}

Copilot AI Jan 22, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The column offset is only applied when row == 0, but rows are being offset unconditionally. This asymmetry could cause incorrect locations for multi-line nodes in nested contexts. Consider whether column offset should apply to all rows or only the first line of the source.

Suggested change
if start_position.row == 0 {
start_column += self.location_base.column;
}
if end_position.row == 0 {
end_column += self.location_base.column;
}
start_column += self.location_base.column;
end_column += self.location_base.column;

Copilot uses AI. Check for mistakes.
Comment thread refcell_eq Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this?

@codecov

codecov Bot commented May 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.00000% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
core/ast/src/parser_context.rs 88.00% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

…ara#66)

Resolves a module name to its sibling `{dir}/{name}.inf` source file
relative to the current file, returning `None` when the file is absent or
the current path has no parent directory.

This is a standalone path-resolution helper with no AST, scope, or grammar
coupling. It is intentionally minimal and not yet wired into compilation,
pending the file-module model tracked in Inferara#63 (so it is not an endorsement of
a Rust-style `mod` hierarchy).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@0xGeorgii 0xGeorgii merged commit e952a52 into Inferara:main May 29, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add multi file support

3 participants