forked from FuelLabs/sway
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dependency.rs
28 lines (25 loc) · 832 Bytes
/
dependency.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use crate::{Parse, ParseResult, Parser};
use sway_ast::dependency::{Dependency, DependencyPath};
impl Parse for DependencyPath {
fn parse(parser: &mut Parser) -> ParseResult<DependencyPath> {
let prefix = parser.parse()?;
let mut suffixes = Vec::new();
while let Some(forward_slash_token) = parser.take() {
let suffix = parser.parse()?;
suffixes.push((forward_slash_token, suffix));
}
Ok(DependencyPath { prefix, suffixes })
}
}
impl Parse for Dependency {
fn parse(parser: &mut Parser) -> ParseResult<Dependency> {
let dep_token = parser.parse()?;
let path = parser.parse()?;
let semicolon_token = parser.parse()?;
Ok(Dependency {
dep_token,
path,
semicolon_token,
})
}
}