On 2012-12-03 13:58, Dexter wrote:
I know you are busy. But I have the feeling you didn't see this email.
So i'll send it again.
I found it! Accidentally overlooked it. My bad :)
By the way, we might as well have this kind of discussion on the mailing list. It's not really a secret, and it shows everybody that something is happening. If you agree, I will forward your notes to the list (or you can do it, so the sender is you)
To put some things on paper, and discuss this with you. Ill send
some thoughts.
Yesterday we discussed the IST, and a bit on what steps to take.
Good with notes :)
We concluded that the IST should be able to represent either python
and javascript.
To make the ist more consise/small, we thought that operators could
be bundled in one IST node; called `operator` with one property, a
string determining the operator in the code.
This is still a bit troublesome imo, since we would have to do
string comparisons/mappings to how this should be represented in
python or javascript: (&& is not and, enz. how to deal with is/is not).
And it means we would have to map it from ast node to string in the
reader, from string to behaviour in the transformers and from string
to string in the writers.
Well, mapping string-to-string is trivial with a dictionary. Mapping class-to-class is a bit more tricky, in my opinion. Yes, you can do it with a dictionary, but it seems somehow less clean to do it polymorphically. Remember, that "and" and "&&" are indeed not the same, but they are both represented by the OP_AND ("&&") operator type. The specialization that turns python into javascript changes OP_AND into GETATTR("__and__") anyway, so this will not be seen by the javascript writer.
So I think we are best off keeping the complete set of AST nodes as
IST. And making the functions deal with those issues.
I still think that a unified op type would be better, but either way is fine. I can see arguments both ways.
In that way the write_And function in the writers can do the thing
they need to do (just return a simple string.
I got a question for you. In the design we have 3 steps drawn out
for the transformers.
__fication, typeification and sematification.
the first one I understand. But I forgot what the others are
supposed to do.
Can you help me out there?
Well, yes, the __fication is obvious. Typeification is another pretty simple step, where we need to turn all literals into python literals. For example, 5 becomes $c5, 42 becomes $PY.int(42) (since it does not have a pre-defined constant), "foo" becomes $PY.str("foo"), and so on.
Finally, semantification is where we change classes, methods and control structures to conform to python semantics. For example, the exception handling is vastly different, and if (foo) needs to be if (js(foo)) and so on. This is what currently represents the bulk of the compiler code.