• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

TyRoXx / NonlocalityOS / 17581344357

09 Sep 2025 11:36AM UTC coverage: 74.9% (-1.7%) from 76.581%
17581344357

push

github

TyRoXx
GH-311: Format

4 of 21 new or added lines in 1 file covered. (19.05%)

158 existing lines in 3 files now uncovered.

3921 of 5235 relevant lines covered (74.9%)

4105.01 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

82.14
/lambda_compiler/src/compilation.rs
1
use crate::{
2
    parsing::{parse_expression_tolerantly, pop_next_non_whitespace_token, ParserOutput},
3
    tokenization::tokenize_default_syntax,
4
    type_checking::{check_types_with_default_globals, TypedExpression},
5
};
6
use arbitrary::Arbitrary;
7
use astraea::storage::StoreError;
8
use lambda::name::NamespaceId;
9
use serde::{Deserialize, Serialize};
10

11
#[derive(
12
    Serialize, Deserialize, Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Hash, Arbitrary,
13
)]
14
pub struct SourceLocation {
15
    pub line: u64,
16
    pub column: u64,
17
}
18

19
impl SourceLocation {
20
    pub fn new(line: u64, column: u64) -> Self {
141✔
21
        Self { line, column }
22
    }
23
}
24

25
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone)]
26
pub struct CompilerError {
27
    pub message: String,
28
    pub location: SourceLocation,
29
}
30

31
impl CompilerError {
32
    pub fn new(message: String, location: SourceLocation) -> Self {
75✔
33
        Self { message, location }
34
    }
35
}
36

37
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone)]
38
pub struct CompilerOutput {
39
    pub entry_point: Option<TypedExpression>,
40
    pub errors: Vec<CompilerError>,
41
}
42

43
impl CompilerOutput {
44
    pub fn new(entry_point: Option<TypedExpression>, errors: Vec<CompilerError>) -> CompilerOutput {
381✔
45
        CompilerOutput {
46
            entry_point,
47
            errors,
48
        }
49
    }
50
}
51

52
pub fn parse_source(source: &str, source_namespace: &NamespaceId) -> ParserOutput {
26✔
53
    let tokens = match tokenize_default_syntax(source) {
52✔
54
        None => {
UNCOV
55
            return ParserOutput {
×
UNCOV
56
                entry_point: None,
×
UNCOV
57
                errors: vec![CompilerError::new(
×
UNCOV
58
                    "Failed to tokenize source code somewhere.".to_string(),
×
UNCOV
59
                    SourceLocation::new(0, 0),
×
60
                )],
61
            }
62
        }
63
        Some(tokens) => tokens,
52✔
64
    };
65
    let mut token_iterator = tokens.iter().peekable();
78✔
66
    let mut result = parse_expression_tolerantly(&mut token_iterator, source_namespace);
104✔
67
    let final_token = pop_next_non_whitespace_token(&mut token_iterator)
78✔
68
        .expect("Expected an end of file token after the entry point lambda");
69
    match &final_token.content {
26✔
70
        crate::tokenization::TokenContent::EndOfFile => {}
25✔
71
        _ => {
1✔
72
            result.errors.push(CompilerError::new(
4✔
73
                "Unexpected token after the entry point lambda".to_string(),
2✔
74
                final_token.location,
1✔
75
            ));
76
        }
77
    }
78
    result
26✔
79
}
80

81
pub async fn compile(
20✔
82
    source: &str,
83
    source_namespace: &NamespaceId,
84
) -> Result<CompilerOutput, StoreError> {
85
    let mut parser_output = parse_source(source, source_namespace);
80✔
86
    match &parser_output.entry_point {
20✔
87
        Some(entry_point) => {
19✔
88
            let type_check_result =
19✔
89
                check_types_with_default_globals(entry_point, *source_namespace).await?;
57✔
90
            parser_output.errors.extend(type_check_result.errors);
91
            Ok(CompilerOutput::new(
92
                type_check_result.entry_point,
93
                parser_output.errors,
94
            ))
95
        }
96
        None => Ok(CompilerOutput::new(None, parser_output.errors)),
1✔
97
    }
98
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc