Do you remember that nifty little hack I sent you a while back. It
was the one that turns off INDENT/DEDENT processing when inside of
parens, curly braces and square brackets. Well, I just found another
use for it. By simply changing two lines in the python grammer, I
have introduced the much debated bracketed block option. So, for
those who choose to use ugly brackets for their blocks and wish to
eschew indentation as a syntactic device they can install the
< simple_stmt: small_stmt (';' small_stmt)* [';'] NEWLINE
--- > simple_stmt: small_stmt (';' small_stmt)* (';' | NEWLINE)
< suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT--- > suite: simple_stmt | [NEWLINE] (INDENT | ':' '(') stmt+ (DEDENT | ':' ')' [NEWLINE])
After making the changes you will need to run pgen from the Parser directory on the new grammer and then move graminit.c to the Python directory adn graminit.h to the Include directory.
With this patch in place you can now write code like this:
if conscience == guilty: :( print 'Sorry Guido... but I could not resist'; :)
Note that the semi-colon is now required at the end of each statement. It's not that I intended this behavior, but a necessary part of the INDENT/DEDENT hack is to also turn off the recognition of NEWLINE as well. The NEWLINE after the first colon is optional, so if you prefer
if 1 == 1: :( print 'Hey'; :)
this style... go right ahead and use it.
Now, for the related lambda problem. By changing one more line in the grammer:
< lambdef: 'lambda' [varargslist] ':' test--- > lambdef: 'lambda' [varargslist] ':' suite
you will (almost) have multi-line lambda expressions. Just remember to terminate simple_stmts with a semi-colon and to use the bracket notation on everything else. Now, the reason I said almost is because the parser accepts the source without a problem, but the generated code tends to cause the intepreter to fall over. If I get time I'll try to figure out why.
______ ______ \_\_\_\ /#/#/#/ \_\_\_\ ______ \_\_\_V#/#/#/ Donald Beaudry email@example.com \_\_/#/#/#/ V. I. Corporation uunet!vicorp!don \_/#/#/#/ 47 Pleasant Street PHONE: (413) 586-4144 V#/#/#/ Northampton, MA 01060 FAX: (413) 586-3805