summaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorSébastien d'Herbais de Thun <sebastien.d.herbais@gmail.com>2024-09-02 15:27:33 +0200
committerGitHub <noreply@github.com>2024-09-02 13:27:33 +0000
commit1997db00f3908967dc381d9a84c0b246700e7112 (patch)
tree255c7da88d19d9f2da9decee5301c52d0be05bde /crates
parentecad396cc8e6a0c5742314907181c939f61ab96d (diff)
Parenthesized imports (#4869)
Co-authored-by: Laurenz <laurmaedje@gmail.com>
Diffstat (limited to 'crates')
-rw-r--r--crates/typst-syntax/src/parser.rs18
1 files changed, 16 insertions, 2 deletions
diff --git a/crates/typst-syntax/src/parser.rs b/crates/typst-syntax/src/parser.rs
index 4ce3917e..aa0431e9 100644
--- a/crates/typst-syntax/src/parser.rs
+++ b/crates/typst-syntax/src/parser.rs
@@ -989,9 +989,22 @@ fn module_import(p: &mut Parser) {
// imported at the same time.
p.expect(SyntaxKind::Ident);
}
- if p.eat_if(SyntaxKind::Colon) && !p.eat_if(SyntaxKind::Star) {
- import_items(p);
+
+ if p.eat_if(SyntaxKind::Colon) {
+ if p.at(SyntaxKind::LeftParen) {
+ let m1 = p.marker();
+ p.enter_newline_mode(NewlineMode::Continue);
+ p.assert(SyntaxKind::LeftParen);
+
+ import_items(p);
+
+ p.expect_closing_delimiter(m1, SyntaxKind::RightParen);
+ p.exit_newline_mode();
+ } else if !p.eat_if(SyntaxKind::Star) {
+ import_items(p);
+ }
}
+
p.wrap(m, SyntaxKind::ModuleImport);
}
@@ -1021,6 +1034,7 @@ fn import_items(p: &mut Parser) {
p.expect(SyntaxKind::Comma);
}
}
+
p.wrap(m, SyntaxKind::ImportItems);
}