diff Parser/tokenizer.c @ 1284:dbce72afe261 legacy-trunk

* selectmodule.c: fix (another!) two memory leaks -- this time in list2set * tokenizer.[ch]: allow continuation without \ inside () [] {}.
author Guido van Rossum <guido@python.org>
date Wed, 12 May 1993 11:35:44 +0000
parents e0464e7115ca
children 132602d854d8
line wrap: on
line diff
--- a/Parser/tokenizer.c	Wed May 12 08:53:36 1993 +0000
+++ b/Parser/tokenizer.c	Wed May 12 11:35:44 1993 +0000
@@ -109,6 +109,7 @@
 	tok->pendin = 0;
 	tok->prompt = tok->nextprompt = NULL;
 	tok->lineno = 0;
+	tok->level = 0;
 	return tok;
 }
 
@@ -390,7 +391,7 @@
 			/* We can't jump back right here since we still
 			   may need to skip to the end of a comment */
 		}
-		if (!blankline) {
+		if (!blankline && tok->level == 0) {
 			if (col == tok->indstack[tok->indent]) {
 				/* No change */
 			}
@@ -483,7 +484,7 @@
 	/* Newline */
 	if (c == '\n') {
 		tok->atbol = 1;
-		if (blankline)
+		if (blankline || tok->level > 0)
 			goto nextline;
 		*p_end = tok->cur - 1; /* Leave '\n' out of the string */
 		return NEWLINE;
@@ -612,6 +613,20 @@
 		tok_backup(tok, c2);
 	}
 	
+	/* Keep track of parenteses nesting level */
+	switch (c) {
+	case '(':
+	case '[':
+	case '{':
+		tok->level++;
+		break;
+	case ')':
+	case ']':
+	case '}':
+		tok->level--;
+		break;
+	}
+	
 	/* Punctuation character */
 	*p_end = tok->cur;
 	return tok_1char(c);