More whitespace fixups
This commit is contained in:
parent
086a2a0f57
commit
e2c9782a65
28
py/lexer.c
28
py/lexer.c
|
@ -504,12 +504,12 @@ STATIC void mp_lexer_next_token_into(mp_lexer_t *lex, mp_token_t *tok, bool firs
|
|||
case 'r': c = 0x0d; break;
|
||||
case 'u':
|
||||
case 'U':
|
||||
if (is_bytes) {
|
||||
// b'\u1234' == b'\\u1234'
|
||||
vstr_add_char(&lex->vstr, '\\');
|
||||
break;
|
||||
}
|
||||
// Otherwise fall through.
|
||||
if (is_bytes) {
|
||||
// b'\u1234' == b'\\u1234'
|
||||
vstr_add_char(&lex->vstr, '\\');
|
||||
break;
|
||||
}
|
||||
// Otherwise fall through.
|
||||
case 'x':
|
||||
{
|
||||
uint num = 0;
|
||||
|
@ -527,7 +527,7 @@ STATIC void mp_lexer_next_token_into(mp_lexer_t *lex, mp_token_t *tok, bool firs
|
|||
// roughly half a meg of storage. This form of Unicode escape may be added
|
||||
// later on, but it's definitely not a priority right now. -- CJA 20140607
|
||||
assert(!"Unicode name escapes not supported");
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
if (c >= '0' && c <= '7') {
|
||||
// Octal sequence, 1-3 chars
|
||||
|
@ -546,13 +546,13 @@ STATIC void mp_lexer_next_token_into(mp_lexer_t *lex, mp_token_t *tok, bool firs
|
|||
}
|
||||
}
|
||||
if (c != MP_LEXER_CHAR_EOF) {
|
||||
if (c < 0x110000 && !is_bytes) {
|
||||
vstr_add_char(&lex->vstr, c);
|
||||
} else if (c < 0x100 && is_bytes) {
|
||||
vstr_add_byte(&lex->vstr, c);
|
||||
} else {
|
||||
assert(!"TODO: Throw an error, invalid escape code probably");
|
||||
}
|
||||
if (c < 0x110000 && !is_bytes) {
|
||||
vstr_add_char(&lex->vstr, c);
|
||||
} else if (c < 0x100 && is_bytes) {
|
||||
vstr_add_byte(&lex->vstr, c);
|
||||
} else {
|
||||
assert(!"TODO: Throw an error, invalid escape code probably");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
vstr_add_char(&lex->vstr, CUR_CHAR(lex));
|
||||
|
|
|
@ -205,20 +205,20 @@ void vstr_add_char(vstr_t *vstr, unichar c) {
|
|||
byte *buf = (byte*)vstr_add_len(vstr, 1);
|
||||
if (buf == NULL) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
*buf = (byte)c;
|
||||
} else if (c < 0x800) {
|
||||
byte *buf = (byte*)vstr_add_len(vstr, 2);
|
||||
if (buf == NULL) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
buf[0] = (c >> 6) | 0xC0;
|
||||
buf[1] = (c & 0x3F) | 0x80;
|
||||
} else if (c < 0x10000) {
|
||||
byte *buf = (byte*)vstr_add_len(vstr, 3);
|
||||
if (buf == NULL) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
buf[0] = (c >> 12) | 0xE0;
|
||||
buf[1] = ((c >> 6) & 0x3F) | 0x80;
|
||||
buf[2] = (c & 0x3F) | 0x80;
|
||||
|
@ -227,7 +227,7 @@ void vstr_add_char(vstr_t *vstr, unichar c) {
|
|||
byte *buf = (byte*)vstr_add_len(vstr, 4);
|
||||
if (buf == NULL) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
buf[0] = (c >> 18) | 0xF0;
|
||||
buf[1] = ((c >> 12) & 0x3F) | 0x80;
|
||||
buf[2] = ((c >> 6) & 0x3F) | 0x80;
|
||||
|
|
Loading…
Reference in New Issue