I spent Thursday working on learning how to override the python keywords. I paired with Aditya on this. I got a head a start reading previous work on this area done by Amy Hanlon & Allison Kaptur such as this and this. Then I learned from Aditya that I can actually create synonyms to the python keywords, I don’t have to use Amy’s method of straight overwriting.
Essentially in the
Grammar/Grammar file in the python repo, you can add synonyms by adding a
| and the keyword you want to use. For example, to make a keyword synonym to the builtin keyword
pass, I would edit the line in the Grammar file like this,
and if I were to compile a python with this change in the grammar file I can have a python interpreter which would declare the following as a valid function.
And the above function is equivalent to me having written this,
But that was too easy… I wanted to create Arabic synonyms to the keywords and this is where I ran into trouble. When I made the following change to the grammar file,
And compiled python with this edit to the Grammar file, the following function didn’t work,
When I created the above function
foo, I would get an error,
Traceback (most recent call last): File "scratch/play.py", line 5, in <module> foo() File "scratch/play.py", line 3, in foo باس NameError: name 'باس' is not defined
I spent the better time of the day going through the python C source code. I started to wonder why there are files with thousands of lines of C code and how in the world this is maintainable. Maybe I struggled because I was uninitiated to the python source. I don’t know…
I then spent a significant amount of time learning about the history of unicode vs ASCII vs other stuff and it was pretty cool. I also read on LTR vs RTL languages. It appears there’s a lot of complexity to non-roman alphabet based languages besides the encoding troubles.