Skip to content

Commit

Permalink
we parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
Lokathor committed Oct 17, 2024
1 parent 1963251 commit 35f4811
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
5 changes: 5 additions & 0 deletions samples/minimum3.yag
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
fn main() {
return

return
}
3 changes: 2 additions & 1 deletion src/bin/yagbas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ fn build_process_file(filename: &String) {
}
};
let tokens: Vec<(Token, FileSpan)> = file_info_id.iter_tokens().collect();
//eprintln!("Tokens: {tokens:?}");
let (token_trees, tree_errors) = parse_tokens_to_token_trees(&tokens);
for tree_error in &tree_errors {
println!("== Tree Error: {tree_error:?}");
Expand All @@ -83,7 +84,7 @@ fn build_process_file(filename: &String) {
println!("I> {item:?}");
}
for item_error in &item_errors {
println!("== Item Error: {item_errors:?}");
println!("== ItemError: {item_error:?}");
}
assert!(item_errors.is_empty());
let mut code_chunks: HashMap<StrID, Vec<u8>> = HashMap::new();
Expand Down
8 changes: 5 additions & 3 deletions src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,17 @@ impl FnDecl {
};
let statements = Statement::parser()
.map_with(|statement, ex| (statement, ex.span()))
.separated_by(line_sep)
.separated_by(line_sep)//.repeated().at_least(1))
.allow_leading()
.allow_trailing()
.collect::<Vec<_>>()
.nested_in(select_ref! {
Braces(b) = ex => {
b.spanned(ex.span())
}
});
})
.labelled("fn_statements")
.as_context();

kw_fn
.ignore_then(fn_name)
Expand Down Expand Up @@ -134,7 +136,7 @@ impl Statement {
inner_self
.clone()
.map_with(|statement, ex| (statement, ex.span()))
.separated_by(line_sep.repeated().at_least(1).ignored())
.separated_by(line_sep.repeated().at_least(1))
.allow_leading()
.allow_trailing()
.collect::<Vec<_>>()
Expand Down

0 comments on commit 35f4811

Please sign in to comment.