File tree Expand file tree Collapse file tree 2 files changed +9148
-8887
lines changed Expand file tree Collapse file tree 2 files changed +9148
-8887
lines changed Original file line number Diff line number Diff line change @@ -26,32 +26,42 @@ pub Top: ast::Mod = {
2626};
2727
2828Program: ast::Suite = {
29- <lines:FileLine*> => {
30- lines.into_iter().flatten().collect()
31- },
32- };
29+ => vec![],
30+ Statements,
3331
34- // A file line either has a declaration, or an empty newline:
35- FileLine: ast::Suite = {
36- Statement,
37- "\n" => vec![],
3832};
3933
4034Suite: ast::Suite = {
41- SimpleStatement,
42- "\n" Indent <s:Statement+> Dedent => s.into_iter().flatten().collect(),
35+ <mut statements:(<SmallStatement> ";")*> <last:SmallStatement> ";"? "\n" => {
36+ statements.push(last);
37+ statements
38+ },
39+ "\n" Indent <s:Statements> Dedent => s,
4340};
4441
45- Statement: ast::Suite = {
46- SimpleStatement,
42+
43+ Statements: Vec<ast::Stmt> = {
44+ // First simple statement
45+ <mut head:(<SmallStatement> ";")*> <last:SmallStatement> ";"? "\n" => {
46+ head.push(last);
47+ head
48+ },
49+
50+ // The first compound statement
4751 <s:CompoundStatement> => vec![s],
48- };
4952
50- SimpleStatement: ast::Suite = {
51- <mut statements:(<SmallStatement> ";")*> <last:SmallStatement> ";"? "\n" => {
53+ // Any subsequent compound statements
54+ <mut statements:Statements> <next:CompoundStatement> => {
55+ statements.push(next);
56+ statements
57+ },
58+
59+ // Any subsequent small statements
60+ <mut statements:Statements> <small:(<SmallStatement> ";")*> <last:SmallStatement> ";"? "\n" => {
61+ statements.extend(small);
5262 statements.push(last);
5363 statements
54- }
64+ },
5565};
5666
5767SmallStatement: ast::Stmt = {
You can’t perform that action at this time.
0 commit comments