properly handle unicode characters in identifiers

This commit is contained in:
ConnorSkees 2020-03-30 00:55:14 -04:00
parent 6608fe3f2f
commit dea0610f9b
2 changed files with 9 additions and 3 deletions

View File

@ -375,7 +375,7 @@ pub(crate) fn eat_ident<I: Iterator<Item = Token>>(
return Err("Expected identifier.".into()); return Err("Expected identifier.".into());
} }
} }
'a'..='z' | 'A'..='Z' | '0'..='9' | '-' | '_' => s.push(toks.next().unwrap().kind), '-' | '_' | _ if tok.kind.is_alphanumeric() => s.push(toks.next().unwrap().kind),
'\\' => { '\\' => {
toks.next(); toks.next();
let mut n = String::new(); let mut n = String::new();
@ -407,6 +407,9 @@ pub(crate) fn eat_ident<I: Iterator<Item = Token>>(
s.push(c); s.push(c);
}; };
} }
_ if !tok.kind.is_ascii() && !tok.kind.is_control() => {
s.push(toks.next().unwrap().kind)
}
_ => break, _ => break,
} }
} }
@ -422,7 +425,7 @@ pub(crate) fn eat_ident_no_interpolation<I: Iterator<Item = Token>>(
'#' => { '#' => {
break; break;
} }
'a'..='z' | 'A'..='Z' | '0'..='9' | '-' | '_' => s.push(toks.next().unwrap().kind), '-' | '_' | _ if tok.kind.is_alphanumeric() => s.push(toks.next().unwrap().kind),
'\\' => { '\\' => {
s.push('\\'); s.push('\\');
toks.next(); toks.next();
@ -436,6 +439,9 @@ pub(crate) fn eat_ident_no_interpolation<I: Iterator<Item = Token>>(
todo!() todo!()
} }
} }
_ if !tok.kind.is_ascii() && !tok.kind.is_control() => {
s.push(toks.next().unwrap().kind)
}
_ => break, _ => break,
} }
} }

View File

@ -365,7 +365,7 @@ impl Value {
Ok(parse_hex(toks, scope, super_selector)?) Ok(parse_hex(toks, scope, super_selector)?)
} }
} }
'a'..='z' | 'A'..='Z' | '_' | '\\' => { '_' | '\\' | _ if kind.is_alphabetic() || (!kind.is_ascii() && !kind.is_control()) => {
let mut s = eat_ident(toks, scope, super_selector)?; let mut s = eat_ident(toks, scope, super_selector)?;
match toks.peek() { match toks.peek() {
Some(Token { kind: '(', .. }) => { Some(Token { kind: '(', .. }) => {