@ else is case sensitive

This commit is contained in:
ConnorSkees 2020-06-01 21:44:07 -04:00
parent 5689ae0131
commit 8846a09d1c
2 changed files with 15 additions and 12 deletions

View File

@ -64,18 +64,16 @@ impl If {
let mut else_ = Vec::new(); let mut else_ = Vec::new();
loop { loop {
match toks.peek().cloned() { if let Some(Token { kind: '@', pos }) = toks.peek().cloned() {
Some(Token { kind: '@', pos }) => { toks.peek_forward(1);
toks.peek_forward(1); let ident = peek_ident_no_interpolation(toks, false, pos)?;
let mut ident = peek_ident_no_interpolation(toks, false, pos)?; if ident.as_str() != "else" {
ident.node.make_ascii_lowercase(); toks.reset_view();
if ident.as_str() != "else" { break;
toks.reset_view();
break;
}
toks.take(4).for_each(drop);
} }
Some(..) | None => break, toks.take(4).for_each(drop);
} else {
break;
} }
devour_whitespace(toks); devour_whitespace(toks);
if let Some(tok) = toks.next() { if let Some(tok) = toks.next() {

View File

@ -106,7 +106,12 @@ test!(
test!( test!(
uppercase_escaped_else, uppercase_escaped_else,
"@if false {}\n\n@\\45lse {\n a {\n color: red;\n }\n}\n", "@if false {}\n\n@\\45lse {\n a {\n color: red;\n }\n}\n",
"a {\n color: red;\n}\n" "@Else {\n a {\n color: red;\n }\n}\n"
);
test!(
uppercase_else,
"@if false {}\n\n@Else {\n a {\n color: red;\n }\n}\n",
"@Else {\n a {\n color: red;\n }\n}\n"
); );
test!(uppercase_if, "@If true {\n a {\n color: red;\n }\n}\n"); test!(uppercase_if, "@If true {\n a {\n color: red;\n }\n}\n");
error!(nothing_after_if, "@if", "Error: Expected expression."); error!(nothing_after_if, "@if", "Error: Expected expression.");