Compare commits

..

2 Commits

2 changed files with 10 additions and 8 deletions

View File

@ -211,14 +211,16 @@ fn Token Lexer.next_token(&lex)
while (ascii::is_alnum_m(lex.peep())) {
if (lex.advance() == 0) { t.type = INVALID; break; }
}
if (lex.off - hex_start != 8) {
io::eprintfn("CSS lexing error at %d:%d: the only suppported color format is #RRGGBBAA", t.line, t.col);
usz h_len = lex.off - hex_start;
if (h_len != 8 && h_len != 6) {
io::eprintfn("CSS lexing error at %d:%d: the only suppported color formats are #RRGGBBAA or #RRGGBB", t.line, t.col);
t.type = INVALID;
break;
}
char[10] hex_str = (char[])"0x";
hex_str[2..] = lex.text[hex_start..lex.off-1];
hex_str[2:h_len] = lex.text[hex_start:h_len];
if (h_len == 6) hex_str[8..9] = "ff"[..];
uint? color_hex = ((String)hex_str[..]).to_uint();
if (catch color_hex) {
t.type = INVALID;

View File

@ -1,5 +1,5 @@
div {
bg: #282828ff;
bg: #282828;
fg: #fbf1c7ff;
primary: #cc241dff;
secondary: #6c19ca8f;