Get it all to compile!

This commit is contained in:
Eric Correia 2021-10-02 13:48:07 -04:00
parent 555478cdf0
commit 8272ea876f
21 changed files with 217 additions and 21 deletions

View file

@ -29,6 +29,7 @@ pub enum Pattern {
NumLiteral(Variable, Box<str>, i64),
FloatLiteral(Variable, Box<str>, f64),
StrLiteral(Box<str>),
SingleQuote(char),
Underscore,
// Runtime Exceptions
@ -89,6 +90,7 @@ pub fn symbols_from_pattern_help(pattern: &Pattern, symbols: &mut Vec<Symbol>) {
| IntLiteral(_, _, _)
| FloatLiteral(_, _, _)
| StrLiteral(_)
| SingleQuote(_)
| Underscore
| MalformedPattern(_, _)
| UnsupportedPattern(_) => {}
@ -237,6 +239,23 @@ pub fn canonicalize_pattern<'a>(
ptype => unsupported_pattern(env, ptype, region),
},
SingleQuote(string) => {
let mut it = string.chars().peekable();
if let Some(char) = it.next() {
if it.peek().is_none() {
Pattern::SingleQuote(char)
} else {
// multiple chars is found
let problem = MalformedPatternProblem::MulitpleCharsInSingleQuote;
malformed_pattern(env, problem, region)
}
} else {
// no characters found
let problem = MalformedPatternProblem::EmptySingleQuote;
malformed_pattern(env, problem, region)
}
}
SpaceBefore(sub_pattern, _) | SpaceAfter(sub_pattern, _) => {
return canonicalize_pattern(env, var_store, scope, pattern_type, sub_pattern, region)
}
@ -476,6 +495,7 @@ fn add_bindings_from_patterns(
| IntLiteral(_, _, _)
| FloatLiteral(_, _, _)
| StrLiteral(_)
| SingleQuote(_)
| Underscore
| Shadowed(_, _)
| MalformedPattern(_, _)