Actually just three programming languages in a trenchcoat
1use super::*;
2use crate::{Parser, Spanned};
3use source_span::Span;
4use trilogy_scanner::{Token, TokenType};
5
6#[derive(Clone, Debug)]
7pub struct UsingStatement {
8 pub head: Option<DoHead>,
9 pub using: Token,
10 pub expression: Expression,
11 pub span: Span,
12}
13
14impl Spanned for UsingStatement {
15 fn span(&self) -> Span {
16 self.span
17 }
18}
19
20impl UsingStatement {
21 pub(crate) fn parse(parser: &mut Parser, head: Option<DoHead>) -> SyntaxResult<Self> {
22 let using = parser.expect(TokenType::KwUsing).unwrap();
23 let expression = Expression::parse(parser)?;
24 let mut span = using.span.union(expression.span());
25 if let Some(head) = &head {
26 span = span.union(head.span());
27 }
28 Ok(Self {
29 span,
30 head,
31 using,
32 expression,
33 })
34 }
35}