swamp_script/
lib.rs

1/*
2 * Copyright (c) Peter Bjorklund. All rights reserved. https://github.com/swamp/script
3 * Licensed under the MIT License. See LICENSE in the project root for license information.
4 */
5use swamp_script_analyzer::prelude::Error;
6use swamp_script_dep_loader::DepLoaderError;
7use swamp_script_source_map::SourceMap;
8pub mod prelude;
9use crate::prelude::SeqMap;
10use swamp_script_analyzer::Program;
11use swamp_script_error_report::ScriptResolveError;
12use swamp_script_semantic::SemanticError;
13use tiny_ver::TinyVersion;
14
15#[derive(Debug)]
16pub enum ScriptError {
17    Error(Error),
18    DepLoaderError(DepLoaderError),
19}
20
21impl From<Error> for ScriptError {
22    fn from(err: Error) -> Self {
23        Self::Error(err)
24    }
25}
26
27impl From<DepLoaderError> for ScriptError {
28    fn from(err: DepLoaderError) -> Self {
29        Self::DepLoaderError(err)
30    }
31}
32
33#[derive(Debug)]
34pub enum LoaderErr {
35    CouldNotLoad,
36    SemanticError(SemanticError),
37    AnalyzerError(Error),
38}
39
40impl From<Error> for LoaderErr {
41    fn from(value: Error) -> Self {
42        LoaderErr::AnalyzerError(value)
43    }
44}
45pub fn compile_and_analyze(
46    module_path: &[String],
47    //version_roots: SeqMap<String, TinyVersion>,
48    source_map: &mut SourceMap,
49) -> Result<Program, ScriptResolveError> {
50    swamp_script_compile::bootstrap_and_compile(source_map, module_path)
51}