End unquoted literals on reserved symbols

This commit is contained in:
Antoine Gersant 2024-09-21 14:20:30 -07:00
parent caf12f23b4
commit e5339ab39a

View file

@ -1,3 +1,5 @@
use std::collections::HashSet;
use chumsky::{
error::Simple,
prelude::{choice, end, filter, just, none_of, recursive},
@ -69,7 +71,9 @@ pub fn make_parser() -> impl Parser<char, Expr, Error = Simple<char>> {
.ignore_then(none_of('"').repeated().collect::<String>())
.then_ignore(just('"'));
let raw_str = filter(|c: &char| !c.is_whitespace() && *c != '"' && *c != '(' && *c != ')')
let symbols = r#"()<>"|&="#.chars().collect::<HashSet<_>>();
let raw_str = filter(move |c: &char| !c.is_whitespace() && !symbols.contains(c))
.repeated()
.at_least(1)
.collect::<String>();