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;
9
10use swamp_script_analyzer::Program;
11use swamp_script_error_report::ScriptResolveError;
12use swamp_script_semantic::SemanticError;
13
14#[derive(Debug)]
15pub enum ScriptError {
16    Error(Error),
17    DepLoaderError(DepLoaderError),
18}
19
20impl From<Error> for ScriptError {
21    fn from(err: Error) -> Self {
22        Self::Error(err)
23    }
24}
25
26impl From<DepLoaderError> for ScriptError {
27    fn from(err: DepLoaderError) -> Self {
28        Self::DepLoaderError(err)
29    }
30}
31
32#[derive(Debug)]
33pub enum LoaderErr {
34    CouldNotLoad,
35    SemanticError(SemanticError),
36    AnalyzerError(Error),
37}
38
39impl From<Error> for LoaderErr {
40    fn from(value: Error) -> Self {
41        LoaderErr::AnalyzerError(value)
42    }
43}
44pub fn compile_and_analyze(
45    module_path: &[String],
46    //version_roots: SeqMap<String, TinyVersion>,
47    source_map: &mut SourceMap,
48) -> Result<Program, ScriptResolveError> {
49    swamp_script_compile::bootstrap_and_compile(source_map, module_path)
50}