disclaimer first : I am writing a compiler so this is black voodoo stuff. I know it, I have put my protecting suit and I wouldn't do it If I could find any other simple way.
The source text is standard python and I transform it into something else using all the runtime type manipulation available. In short, all the standard types are enhanced with meta-data. Currently List is the only type which is not a leaf type and is standard. ( dict is in the same category but I didn't try yet to transform it, I would likely have the same problem ). Leaf types (int, str, bool, float) are ok, as are classes.
To elegantly replace the standard list by my enhanced list datatype is one swooop, I would like to change the default behavior of the token []
in python text, instead of returning a list, it should return my list-like type.
But I don't see any way to intercepting this token.
( I can override the token list
via sys.modules[__builtins__]
, but []
seems beyond reach. )
Any idea ?