aboutsummaryrefslogtreecommitdiff
path: root/src/parser/event_parser/grammar/items.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/parser/event_parser/grammar/items.rs')
-rw-r--r--src/parser/event_parser/grammar/items.rs56
1 files changed, 55 insertions, 1 deletions
diff --git a/src/parser/event_parser/grammar/items.rs b/src/parser/event_parser/grammar/items.rs
index f7310c09a..2f64111ab 100644
--- a/src/parser/event_parser/grammar/items.rs
+++ b/src/parser/event_parser/grammar/items.rs
@@ -74,9 +74,63 @@ fn mod_item(p: &mut Parser) {
74 p.curly_block(mod_contents); 74 p.curly_block(mod_contents);
75} 75}
76 76
77pub(super) fn is_use_tree_start(kind: SyntaxKind) -> bool {
78 kind == STAR || kind == L_CURLY
79}
80
77fn use_item(p: &mut Parser) { 81fn use_item(p: &mut Parser) {
78 paths::use_path(p); 82 use_tree(p);
79 p.expect(SEMI); 83 p.expect(SEMI);
84
85 fn use_tree(p: &mut Parser) -> bool{
86 if node_if(p, STAR, USE_TREE, |_| ()) {
87 return true
88 }
89 if node_if(p, [COLONCOLON, STAR], USE_TREE, |_| ()) {
90 return true
91 }
92 if [COLONCOLON, L_CURLY].is_ahead(p) || L_CURLY.is_ahead(p) {
93 node(p, USE_TREE, |p| {
94 p.eat(COLONCOLON);
95 p.curly_block(|p| {
96 comma_list(p, EOF, use_tree);
97 });
98 });
99 return true;
100 }
101 if paths::is_path_start(p) {
102 node(p, USE_TREE, |p| {
103 paths::use_path(p);
104 match p.current() {
105 AS_KW => {
106 alias(p);
107 }
108 COLONCOLON => {
109 p.bump();
110 match p.current() {
111 STAR => {
112 p.bump();
113 }
114 L_CURLY => {
115 p.curly_block(|p| {
116 comma_list(p, EOF, use_tree);
117 });
118 }
119 _ => {
120 // is this unreachable?
121 p.error()
122 .message("expected `{` or `*`")
123 .emit();
124 }
125 }
126 }
127 _ => (),
128 }
129 });
130 return true;
131 }
132 false
133 }
80} 134}
81 135
82fn struct_field(p: &mut Parser) -> bool { 136fn struct_field(p: &mut Parser) -> bool {