[Python-ideas] Needing help to change the grammar

Nick Coghlan ncoghlan at gmail.com
Sat Apr 18 15:52:49 CEST 2009


(moving discussion to Python Ideas)

(Context for py-ideas: a teacher in Brazil is working on a Python
language variant that uses Portuguese rather than English-based
keywords. This is intended for use in teaching introductory programming
lessons, not as a professional development tool)

Glenn Linderman wrote:
> import pt_BR
> 
> An implementation along that line, except for things like reversing the
> order of "not" and "is", would allow the next national language
> customization to be done by just recoding the pt_BR module, renaming to
> pt_it or pt_fr or pt_no and translating a bunch of strings, no?
> 
> Probably it would be sufficient to allow for one language at a time, per
> module.

Making that work would actually require something like the file encoding
cookie that is detected at the parsing stage. Otherwise the parser and
compiler would choke on the unexpected keywords long before the
interpreter reached the stage of attempting to import anything.

Adjusting the parser to accept different keyword names would be even
more difficult though, since changing the details of the grammar
definition is a lot more invasive than just changing the encoding of the
file being read.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------



More information about the Python-ideas mailing list