Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions crates/parser/src/grammar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,17 @@ pub(crate) mod entry {

pub(crate) fn source_file(p: &mut Parser<'_>) {
let m = p.start();
// test frontmatter
// #!/usr/bin/env cargo
//
// ---
// [dependencies]
// clap = { version = "4.2", features = ["derive"] }
// ---
//
// fn main() {}
p.eat(SHEBANG);
p.eat(FRONTMATTER);
items::mod_contents(p, false);
m.complete(p, SOURCE_FILE);
}
Expand Down
2 changes: 2 additions & 0 deletions crates/parser/test_data/generated/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,8 @@ mod ok {
#[test]
fn for_type() { run_and_expect_no_errors("test_data/parser/inline/ok/for_type.rs"); }
#[test]
fn frontmatter() { run_and_expect_no_errors("test_data/parser/inline/ok/frontmatter.rs"); }
#[test]
fn full_range_expr() {
run_and_expect_no_errors("test_data/parser/inline/ok/full_range_expr.rs");
}
Expand Down
18 changes: 18 additions & 0 deletions crates/parser/test_data/parser/inline/ok/frontmatter.rast
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
SOURCE_FILE
SHEBANG "#!/usr/bin/env cargo\n"
FRONTMATTER "\n---\n[dependencies]\nclap = { version = \"4.2\", features = [\"derive\"] }\n---\n"
WHITESPACE "\n"
FN
FN_KW "fn"
WHITESPACE " "
NAME
IDENT "main"
PARAM_LIST
L_PAREN "("
R_PAREN ")"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
R_CURLY "}"
WHITESPACE "\n"
8 changes: 8 additions & 0 deletions crates/parser/test_data/parser/inline/ok/frontmatter.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env cargo

---
[dependencies]
clap = { version = "4.2", features = ["derive"] }
---

fn main() {}