MCPcopy Create free account
hub / github.com/Voxon-Development/zeta-lang / parse_program

Function parse_program

scribe-parser/src/parser/descent_parser.rs:152–187  ·  view source on GitHub ↗
(
    src: StrId,
    file_name: &'bump str,
    context: Arc<StringPool>,
    bump: Arc<GrowableAtomicBump<'bump>>,
)

Source from the content-addressed store, hash-verified

150 }
151
152 TokenKind::Mut => {
153 // Check for shorthand let (ident := expr)
154 if self.cursor.peek_n(1) == TokenKind::Ident
155 && self.cursor.peek_n(2) == TokenKind::ColonAssign
156 {
157 self.parse_shorthand_let_stmt()
158 } else {
159 self.parse_expr_stmt()
160 }
161 }
162
163 _ => self.parse_expr_stmt(),
164 }
165 }
166}
167
168pub fn token_to_visibility(token_kind: TokenKind) -> Visibility {
169 match token_kind {
170 TokenKind::Private => Visibility::Private,
171 TokenKind::Module => Visibility::Module,
172 TokenKind::Package => Visibility::Internal,
173 _ => Visibility::Public,
174 }
175}
176
177#[derive(Debug)]
178pub struct ParseResult<'a, 'bump> {
179 pub statements: Vec<Stmt<'a, 'bump>, Arc<GrowableAtomicBump<'bump>>>,
180 pub diagnostics: ParserDiagnostics<'a>,
181}
182
183pub fn parse_program<'a, 'bump>(
184 src: &str,
185 file_name: &'bump str,
186 context: Arc<StringPool>,
187 bump: Arc<GrowableAtomicBump<'bump>>,
188) -> ParseResult<'a, 'bump> {
189 let lexer: Lexer = Lexer::new(context.clone());
190 let tokens: Tokens<'a, 'bump> = lexer.tokenize(src, file_name, bump.clone());

Callers 15

parse_single_fileFunction · 0.85
parse_and_lowerFunction · 0.85
test_struct_fields_astFunction · 0.85
test_if_else_astFunction · 0.85
test_while_loop_astFunction · 0.85
test_for_loop_astFunction · 0.85
test_match_stmt_astFunction · 0.85
test_impl_methods_astFunction · 0.85
test_defer_astFunction · 0.85

Calls 7

cloneMethod · 0.80
tokenizeMethod · 0.80
parse_toplevelMethod · 0.80
into_diagnosticsMethod · 0.80
as_strMethod · 0.45
alloc_valueMethod · 0.45
recordMethod · 0.45

Tested by 15

parse_and_lowerFunction · 0.68
test_struct_fields_astFunction · 0.68
test_if_else_astFunction · 0.68
test_while_loop_astFunction · 0.68
test_for_loop_astFunction · 0.68
test_match_stmt_astFunction · 0.68
test_impl_methods_astFunction · 0.68
test_defer_astFunction · 0.68
test_enum_decl_hirFunction · 0.68