Something went wrong. Try again.
Actually just three programming languages in a trenchcoat
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738use super::*;use crate::{Parser, Spanned};use source_span::Span;use trilogy_scanner::{Token, TokenType};
#[derive(Clone, Debug, PrettyPrintSExpr)]pub struct TestDefinition { pub test: Token, pub not: Option<Token>, pub name: StringLiteral, pub body: Block, span: Span,}
impl Spanned for TestDefinition { fn span(&self) -> Span { self.span }}
impl TestDefinition { pub(crate) fn parse(parser: &mut Parser) -> SyntaxResult<Self> { let test = parser .expect(TokenType::KwTest) .expect("Caller should find `test` keyword."); let not = parser.expect(TokenType::KwNot).ok(); let name = StringLiteral::parse(parser)?; let body = Block::parse(parser)?; Ok(Self { span: test.span.union(body.span()), test, not, name, body, }) }}