[3.9] Improve readability and style in parser files (GH-20884) (GH-20885)

(cherry picked from commit fb61c42)

Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
diff --git a/Parser/pegen/pegen.c b/Parser/pegen/pegen.c
index ca1e9bb..9513f91 100644
--- a/Parser/pegen/pegen.c
+++ b/Parser/pegen/pegen.c
@@ -67,10 +67,11 @@
     assert(t->type == NOTEQUAL);
 
     char* tok_str = PyBytes_AS_STRING(t->bytes);
-    if (p->flags & PyPARSE_BARRY_AS_BDFL && strcmp(tok_str, "<>")){
+    if (p->flags & PyPARSE_BARRY_AS_BDFL && strcmp(tok_str, "<>") != 0) {
         RAISE_SYNTAX_ERROR("with Barry as BDFL, use '<>' instead of '!='");
         return -1;
-    } else if (!(p->flags & PyPARSE_BARRY_AS_BDFL)) {
+    }
+    if (!(p->flags & PyPARSE_BARRY_AS_BDFL)) {
         return strcmp(tok_str, "!=");
     }
     return 0;
@@ -245,7 +246,10 @@
         errtype = "value error";
     }
     if (errtype) {
-        PyObject *type, *value, *tback, *errstr;
+        PyObject *type;
+        PyObject *value;
+        PyObject *tback;
+        PyObject *errstr;
         PyErr_Fetch(&type, &value, &tback);
         errstr = PyObject_Str(value);
         if (errstr) {
@@ -274,7 +278,9 @@
     }
     PyObject *errstr = NULL;
     PyObject *tuple = NULL;
-    PyObject *type, *value, *tback;
+    PyObject *type;
+    PyObject *value;
+    PyObject *tback;
     PyErr_Fetch(&type, &value, &tback);
     errstr = PyObject_Str(value);
     if (!errstr) {
@@ -548,7 +554,8 @@
 int
 _PyPegen_fill_token(Parser *p)
 {
-    const char *start, *end;
+    const char *start;
+    const char *end;
     int type = PyTokenizer_Get(p->tok, &start, &end);
 
     // Record and skip '# type: ignore' comments
@@ -589,9 +596,8 @@
             PyErr_NoMemory();
             return -1;
         }
-        else {
-            p->tokens = new_tokens;
-        }
+        p->tokens = new_tokens;
+
         for (int i = p->size; i < newsize; i++) {
             p->tokens[i] = PyMem_Malloc(sizeof(Token));
             if (p->tokens[i] == NULL) {
@@ -615,7 +621,8 @@
     int lineno = type == STRING ? p->tok->first_lineno : p->tok->lineno;
     const char *line_start = type == STRING ? p->tok->multi_line_start : p->tok->line_start;
     int end_lineno = p->tok->lineno;
-    int col_offset = -1, end_col_offset = -1;
+    int col_offset = -1;
+    int end_col_offset = -1;
     if (start != NULL && start >= line_start) {
         col_offset = (int)(start - line_start);
     }
@@ -634,9 +641,8 @@
         if (p->tok->done == E_DECODE) {
             return raise_decode_error(p);
         }
-        else {
-            return tokenizer_error(p);
-        }
+        return tokenizer_error(p);
+
     }
 
     return 0;
@@ -846,33 +852,36 @@
             return PyLong_FromString(s, (char **)0, 0);
         }
     }
-    else
+    else {
         x = PyOS_strtol(s, (char **)&end, 0);
+    }
     if (*end == '\0') {
-        if (errno != 0)
+        if (errno != 0) {
             return PyLong_FromString(s, (char **)0, 0);
+        }
         return PyLong_FromLong(x);
     }
     /* XXX Huge floats may silently fail */
     if (imflag) {
         compl.real = 0.;
         compl.imag = PyOS_string_to_double(s, (char **)&end, NULL);
-        if (compl.imag == -1.0 && PyErr_Occurred())
+        if (compl.imag == -1.0 && PyErr_Occurred()) {
             return NULL;
+        }
         return PyComplex_FromCComplex(compl);
     }
-    else {
-        dx = PyOS_string_to_double(s, NULL, NULL);
-        if (dx == -1.0 && PyErr_Occurred())
-            return NULL;
-        return PyFloat_FromDouble(dx);
+    dx = PyOS_string_to_double(s, NULL, NULL);
+    if (dx == -1.0 && PyErr_Occurred()) {
+        return NULL;
     }
+    return PyFloat_FromDouble(dx);
 }
 
 static PyObject *
 parsenumber(const char *s)
 {
-    char *dup, *end;
+    char *dup;
+    char *end;
     PyObject *res = NULL;
 
     assert(s != NULL);