aboutsummaryrefslogtreecommitdiff
path: root/py/lexer.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2020-02-27 15:36:53 +1100
committerDamien George <damien.p.george@gmail.com>2020-02-28 10:33:03 +1100
commit69661f3343bedf86e514337cff63d96cc42f8859 (patch)
treeaf5dfb380ffdb75dda84828f63cf9d840d992f0f /py/lexer.c
parent3f39d18c2b884d32f0443e2e8114ff9d7a14d718 (diff)
all: Reformat C and Python source code with tools/codeformat.py.
This is run with uncrustify 0.70.1, and black 19.10b0.
Diffstat (limited to 'py/lexer.c')
-rw-r--r--py/lexer.c54
1 files changed, 36 insertions, 18 deletions
diff --git a/py/lexer.c b/py/lexer.c
index 5f8adda91..73ff5ecad 100644
--- a/py/lexer.c
+++ b/py/lexer.c
@@ -105,9 +105,9 @@ STATIC bool is_following_odigit(mp_lexer_t *lex) {
STATIC bool is_string_or_bytes(mp_lexer_t *lex) {
return is_char_or(lex, '\'', '\"')
- || (is_char_or3(lex, 'r', 'u', 'b') && is_char_following_or(lex, '\'', '\"'))
- || ((is_char_and(lex, 'r', 'b') || is_char_and(lex, 'b', 'r'))
- && is_char_following_following_or(lex, '\'', '\"'));
+ || (is_char_or3(lex, 'r', 'u', 'b') && is_char_following_or(lex, '\'', '\"'))
+ || ((is_char_and(lex, 'r', 'b') || is_char_and(lex, 'b', 'r'))
+ && is_char_following_following_or(lex, '\'', '\"'));
}
// to easily parse utf-8 identifiers we allow any raw byte with high bit set
@@ -307,17 +307,36 @@ STATIC void parse_string_literal(mp_lexer_t *lex, bool is_raw) {
switch (c) {
// note: "c" can never be MP_LEXER_EOF because next_char
// always inserts a newline at the end of the input stream
- case '\n': c = MP_LEXER_EOF; break; // backslash escape the newline, just ignore it
- case '\\': break;
- case '\'': break;
- case '"': break;
- case 'a': c = 0x07; break;
- case 'b': c = 0x08; break;
- case 't': c = 0x09; break;
- case 'n': c = 0x0a; break;
- case 'v': c = 0x0b; break;
- case 'f': c = 0x0c; break;
- case 'r': c = 0x0d; break;
+ case '\n':
+ c = MP_LEXER_EOF;
+ break; // backslash escape the newline, just ignore it
+ case '\\':
+ break;
+ case '\'':
+ break;
+ case '"':
+ break;
+ case 'a':
+ c = 0x07;
+ break;
+ case 'b':
+ c = 0x08;
+ break;
+ case 't':
+ c = 0x09;
+ break;
+ case 'n':
+ c = 0x0a;
+ break;
+ case 'v':
+ c = 0x0b;
+ break;
+ case 'f':
+ c = 0x0c;
+ break;
+ case 'r':
+ c = 0x0d;
+ break;
case 'u':
case 'U':
if (lex->tok_kind == MP_TOKEN_BYTES) {
@@ -325,9 +344,8 @@ STATIC void parse_string_literal(mp_lexer_t *lex, bool is_raw) {
vstr_add_char(&lex->vstr, '\\');
break;
}
- // Otherwise fall through.
- case 'x':
- {
+ // Otherwise fall through.
+ case 'x': {
mp_uint_t num = 0;
if (!get_hex(lex, (c == 'x' ? 2 : c == 'u' ? 4 : 8), &num)) {
// not enough hex chars for escape sequence
@@ -707,7 +725,7 @@ mp_lexer_t *mp_lexer_new(qstr src_name, mp_reader_t reader) {
mp_lexer_t *mp_lexer_new_from_str_len(qstr src_name, const char *str, size_t len, size_t free_len) {
mp_reader_t reader;
- mp_reader_new_mem(&reader, (const byte*)str, len, free_len);
+ mp_reader_new_mem(&reader, (const byte *)str, len, free_len);
return mp_lexer_new(src_name, reader);
}