[Types-sig] question regarding adding words to the grammar

scott scott@chronis.pobox.com
Wed, 19 Jan 2000 19:37:36 -0500


While I have worked with the pythons grammar to play with type
checking, I found that no matter where a word is introduced in the
grammar, it causes that word to become a keyword, even if that word
cannot appear where a regular variable name might.

For example, one thing that I once attempted as a way of declaring
classes relationships to interfaces was:

classdef: class NAME ['(' NAME (',' NAME)* ')'] ['implements' NAME] ':' suite

However, when I compiled python with this grammar, it wouldn't let me
use the word 'implements' as a variable name (gives SyntaxError).

So the question is:  If you can introduce context-sensitive words, how
do you do it without making a mess out of the grammar and hacking
compile.c?


scott