[Python-Dev] Making None a keyword

Guido van Rossum guido@python.org
Fri, 26 Apr 2002 08:42:56 -0400


Here's what I have so far. :-)

*** Grammar/Grammar	15 Oct 2001 15:44:04 -0000	1.45
--- Grammar/Grammar	26 Apr 2002 12:30:36 -0000
***************
*** 80,86 ****
  term: factor (('*'|'/'|'%'|'//') factor)*
  factor: ('+'|'-'|'~') factor | power
  power: atom trailer* ('**' factor)*
! atom: '(' [testlist] ')' | '[' [listmaker] ']' | '{' [dictmaker] '}' | '`' testlist '`' | NAME | NUMBER | STRING+
  listmaker: test ( list_for | (',' test)* [','] )
  lambdef: 'lambda' [varargslist] ':' test
  trailer: '(' [arglist] ')' | '[' subscriptlist ']' | '.' NAME
--- 80,86 ----
  term: factor (('*'|'/'|'%'|'//') factor)*
  factor: ('+'|'-'|'~') factor | power
  power: atom trailer* ('**' factor)*
! atom: '(' [testlist] ')' | '[' [listmaker] ']' | '{' [dictmaker] '}' | '`' testlist '`' | NAME | NUMBER | STRING+ | 'None'
  listmaker: test ( list_for | (',' test)* [','] )
  lambdef: 'lambda' [varargslist] ':' test
  trailer: '(' [arglist] ')' | '[' subscriptlist ']' | '.' NAME

It needs to add 'None' as an alternative to all other places where
currently NAME occurs.

The Unix Makefile automatically regenerates Includes/graminit.h and
Python/graminit.c when you touch Grammar/Grammar.

For some mysterious reason, I didn't have to change the code generator
at all -- the NAME terminals and the 'None' terminal look the same to
it. :-)

--Guido van Rossum (home page: http://www.python.org/~guido/)