Actually just three programming languages in a trenchcoat
at main 31 lines 704 B view raw
1use super::*; 2use crate::{Parser, Spanned}; 3use source_span::Span; 4use trilogy_scanner::{Token, TokenType}; 5 6#[derive(Clone, Debug)] 7pub struct ModuleAccess { 8 pub lhs: Expression, 9 pub access: Token, 10 pub rhs: Identifier, 11 pub span: Span, 12} 13 14impl Spanned for ModuleAccess { 15 fn span(&self) -> Span { 16 self.span 17 } 18} 19 20impl ModuleAccess { 21 pub(crate) fn parse(parser: &mut Parser, lhs: Expression) -> SyntaxResult<Self> { 22 let access = parser.expect(TokenType::OpColonColon).unwrap(); 23 let rhs = Identifier::parse(parser)?; 24 Ok(Self { 25 span: lhs.span().union(rhs.span()), 26 lhs, 27 access, 28 rhs, 29 }) 30 } 31}