Re: continuation lines

Guido.van.Rossum@cwi.nl
Fri, 14 May 1993 10:06:38 +0200

> I would very much like to see this mod posted somewhere as this would
> make some lists that I am building up (100+ elements) much easier to
> code! I also think it fits very nicely with other languages...

Unfortunately the author of the mod found it necessary to reformat the
file before making the changes :-(. I have retrofitted it in my
current source but that also contains another fix, so I can't
guarantee that the following diff will work with a clean 0.9.8 source.
Below is the diff for tokenizer.c; you also need to add "int level;"
to the end of the struct defined in tokenizer.h.

--Guido van Rossum, CWI, Amsterdam <Guido.van.Rossum@cwi.nl>

*** 2.12 1993/05/12 08:24:17
--- tokenizer.c 1993/05/12 11:35:42
***************
*** 111,112 ****
--- 111,113 ----
tok->lineno = 0;
+ tok->level = 0;
return tok;
***************
*** 392,394 ****
}
! if (!blankline) {
if (col == tok->indstack[tok->indent]) {
--- 393,395 ----
}
! if (!blankline && tok->level == 0) {
if (col == tok->indstack[tok->indent]) {
***************
*** 485,487 ****
tok->atbol = 1;
! if (blankline)
goto nextline;
--- 486,488 ----
tok->atbol = 1;
! if (blankline || tok->level > 0)
goto nextline;
***************
*** 612,613 ****
--- 613,628 ----
tok_backup(tok, c2);
+ }
+
+ /* Keep track of parenteses nesting level */
+ switch (c) {
+ case '(':
+ case '[':
+ case '{':
+ tok->level++;
+ break;
+ case ')':
+ case ']':
+ case '}':
+ tok->level--;
+ break;
}