Add unknown ranges and open object values

This commit is contained in:
2026-08-14 08:00:22 +09:00
parent 8c50dd202d
commit 848c7f169f
53 changed files with 9047 additions and 6572 deletions
+13 -7
View File
@@ -5,10 +5,16 @@ use std::{
};
use decodal::{
Data, Diagnostic, DiagnosticKind, Engine, ImportLoader, LoadedImport, LoadedSource, SourceId,
Span, format_diagnostic_with,
Data, Diagnostic, DiagnosticKind, Engine, ImportLoader, LoadedImport, SourceId, Span,
format_diagnostic_with,
};
struct SourceInput {
key: String,
name: String,
source: String,
}
fn main() -> ExitCode {
match run() {
Ok(()) => ExitCode::SUCCESS,
@@ -69,7 +75,7 @@ fn materialize_path(path: &str) -> Result<Data, String> {
.map_err(|error| engine.format_diagnostic(&error))
}
fn read_root_source(path: &str) -> Result<LoadedSource, Diagnostic> {
fn read_root_source(path: &str) -> Result<SourceInput, Diagnostic> {
if path == "-" {
use std::io::Read;
let mut source = String::new();
@@ -82,7 +88,7 @@ fn read_root_source(path: &str) -> Result<LoadedSource, Diagnostic> {
format!("failed to read stdin: {error}"),
)
})?;
Ok(LoadedSource {
Ok(SourceInput {
key: String::from("<stdin>"),
name: String::from("<stdin>"),
source,
@@ -112,11 +118,11 @@ impl ImportLoader for FsLoader {
} else {
PathBuf::from(path)
};
load_path(&path).map(LoadedImport::Source)
load_path(&path).map(|source| LoadedImport::source(source.key, source.name, source.source))
}
}
fn load_path(path: &Path) -> Result<LoadedSource, Diagnostic> {
fn load_path(path: &Path) -> Result<SourceInput, Diagnostic> {
let canonical = path.canonicalize().map_err(|error| {
Diagnostic::new(
DiagnosticKind::Import,
@@ -132,7 +138,7 @@ fn load_path(path: &Path) -> Result<LoadedSource, Diagnostic> {
)
})?;
let key = canonical.to_string_lossy().into_owned();
Ok(LoadedSource {
Ok(SourceInput {
name: key.clone(),
key,
source,