Skip to content

Commit c89f2e0

Browse files
committed
permit comments in between items
1 parent 8ebb46d commit c89f2e0

File tree

3 files changed

+3437
-3113
lines changed

3 files changed

+3437
-3113
lines changed

chalk-parse/src/parser.lalrpop

+12-5
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,22 @@ use lalrpop_intern::intern;
44
grammar;
55

66
pub Program: Program = {
7-
Item* => Program { items: <> }
7+
Items => Program { items: <> }
88
};
99

10-
Item: Item = {
11-
StructDefn => Item::StructDefn(<>),
12-
TraitDefn => Item::TraitDefn(<>),
13-
Impl => Item::Impl(<>),
10+
Items: Vec<Item> = {
11+
Item* => <>.into_iter().filter_map(|v| v).collect()
1412
};
1513

14+
Item: Option<Item> = {
15+
Comment => None,
16+
StructDefn => Some(Item::StructDefn(<>)),
17+
TraitDefn => Some(Item::TraitDefn(<>)),
18+
Impl => Some(Item::Impl(<>)),
19+
};
20+
21+
Comment: () = r"//.*";
22+
1623
pub Goal: Box<Goal> = {
1724
Goal1,
1825
<g1:Goal1> "," <g2:Goal> => Box::new(Goal::And(g1, g2)),

0 commit comments

Comments
 (0)