Handle utf8 input (a bit)
This commit is contained in:
parent
ef4a9e9ded
commit
4c3f5e24ee
@ -134,7 +134,10 @@ impl<'a> Iterator for Lexer<'a> {
|
||||
'<' => symbol!(self, Lt),
|
||||
'>' => symbol!(self, Gt),
|
||||
'\0' => return None,
|
||||
_ => todo!("unknown char"),
|
||||
&v => {
|
||||
self.buf.next();
|
||||
TokenKind::Unknown(v.clone())
|
||||
}
|
||||
};
|
||||
self.pos.next_char();
|
||||
Some(Token {
|
||||
|
@ -151,6 +151,7 @@ pub(crate) enum TokenKind {
|
||||
Op(Op),
|
||||
MultilineComment(String),
|
||||
Interpolation,
|
||||
Unknown(char),
|
||||
}
|
||||
|
||||
impl TokenKind {
|
||||
@ -172,6 +173,7 @@ impl Display for TokenKind {
|
||||
TokenKind::Keyword(kw) => write!(f, "{}", kw),
|
||||
TokenKind::MultilineComment(s) => write!(f, "/*{}*/", s),
|
||||
TokenKind::Variable(s) => write!(f, "{}", s),
|
||||
TokenKind::Unknown(s) => write!(f, "{}", s),
|
||||
TokenKind::Interpolation => {
|
||||
panic!("we don't want to format TokenKind::Interpolation using Display")
|
||||
}
|
||||
|
@ -343,6 +343,7 @@ impl Value {
|
||||
TokenKind::Keyword(Keyword::True) => Ok(Value::True),
|
||||
TokenKind::Keyword(Keyword::False) => Ok(Value::False),
|
||||
TokenKind::Keyword(Keyword::Null) => Ok(Value::Null),
|
||||
TokenKind::Unknown(c) => Ok(Value::Ident(c.to_string(), QuoteKind::None)),
|
||||
_ => Err("Unexpected token in value parsing".into()),
|
||||
}
|
||||
}
|
||||
|
@ -27,3 +27,4 @@ test!(
|
||||
"$a-b: red; $a_b: green; a {\n color: $a-b;\n}\n",
|
||||
"a {\n color: green;\n}\n"
|
||||
);
|
||||
test!(utf8_input, "a {\n color: 🦆;\n}\n");
|
||||
|
Loading…
x
Reference in New Issue
Block a user