tinyscript 0.6.1

Tiny, C-like scripting language.
Documentation
// Copyright © 2025 Stephan Kunz
//! [`GroupingParselet`] handles parentheses.

use crate::{
	compilation::{
		CompilationError, Lexer, Parser,
		token::{Token, TokenKind},
	},
	execution::Chunk,
};

use super::PrefixParselet;

#[derive(Clone)]
pub struct GroupingParselet;

impl PrefixParselet for GroupingParselet {
	fn parse(
		&self,
		lexer: &mut Lexer,
		parser: &mut Parser,
		chunk: &mut Chunk,
		_token: Token,
	) -> Result<(), CompilationError> {
		parser.expression(lexer, chunk)?;
		parser.consume(lexer, TokenKind::RightParen)
	}
}

#[cfg(test)]
mod tests {
	use super::*;

	// check, that the auto traits are available
	const fn is_normal<T: Sized + Send + Sync>() {}

	#[test]
	const fn normal_types() {
		is_normal::<&GroupingParselet>();
		is_normal::<GroupingParselet>();
	}
}