1
0
Fork 0
mirror of https://github.com/imjasonh/nescript synced 2026-07-10 01:37:45 +00:00

Add include directive for multi-file projects

Parser/preprocess module:
- New src/parser/preprocess.rs handles source-level include inlining
- 'include "path"' at line start splices the target file's content
- Paths resolved relative to the including file's directory
- Circular include detection via visited set (canonicalized paths)
- Non-cycle re-includes allowed (sibling branches can reuse files)

main.rs:
- Both compile() and check() run preprocess_source() before parsing
- Include resolution failures produce a clear error message

Tests: 4 new preprocess unit tests (249 total)
- passthrough, include line parsing, temp-file roundtrip

https://claude.ai/code/session_01W6eQFStA66EuMKHUFo2rx3
This commit is contained in:
Claude 2026-04-12 10:06:58 +00:00
parent 18e9bed258
commit 6efef6c4c5
No known key found for this signature in database
3 changed files with 140 additions and 2 deletions

View file

@ -1,7 +1,10 @@
pub mod ast;
pub mod preprocess;
#[cfg(test)]
mod tests;
pub use preprocess::preprocess as preprocess_source;
use crate::errors::{Diagnostic, ErrorCode};
use crate::lexer::{Span, Token, TokenKind};
use ast::*;