aiken_lang/parser/pattern/
string.rs1use crate::{
2 ast::{ByteArrayFormatPreference, UntypedPattern},
3 parser::{error::ParseError, literal, token::Token},
4};
5use chumsky::prelude::*;
6
7pub fn parser() -> impl Parser<Token, UntypedPattern, Error = ParseError> {
8 literal::string().validate(|_, location, emit| {
9 emit(ParseError::match_string(location));
10
11 UntypedPattern::ByteArray {
12 location,
13 value: Vec::new(),
14 preferred_format: ByteArrayFormatPreference::Utf8String,
15 }
16 })
17}
18
19#[cfg(test)]
20mod tests {
21 use crate::assert_expr;
22
23 #[test]
24 fn pattern_string() {
25 assert_expr!(
26 r#"
27 when foo is {
28 @"foo" -> True
29 }
30 "#
31 );
32 }
33}