Calypso
Calypso copied to clipboard
parse: allow 'function' keyword to propogate through to Calypso
This change allows
import (C++) std._ : cppfunc = function;
Then we can almost instantiate cppfunc when combined with the member function pointer pull request. This may be useful in other situations as C++ programmers may use 'function' in other cases, as well.
Yes C++ identifiers that are keywords in D are broken. If it's just during the parsing we could make a hack for every D keyword not present in D, or maybe force the lexer to read identifiers. Could you look into that and make a more comprehensive hack?
I also got errors with "out" and "in" during the semantic phase yesterday, I was wondering if this has something to do with that are or if it's related to a recent change I made in my tree. Probably the latter (I hope).
Hello Elie,
I’ll take a look at the more comprehensive hack for identifiers.
With those couple additions for the last couple PR’s and returning NullExp(loc) for these:
isa<clang::CXXDependentScopeMemberExpr>(E) ||
isa<clang::CXXPseudoDestructorExpr>(E) ||
Then we are really close to compiling
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/type_traits(133): Error: alias cpp.std.__sfinae_types.__sfinae_types.__two conflicts with struct cpp.std.__sfinae_types.__sfinae_types.__two at /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/type_traits(133)
Aliasing a typedef ‘d struct inside a struct isn’t working correctly, I guess. Not sure why.
Thanks,
Kelly
From: Elie Morisse [mailto:[email protected]] Sent: Tuesday, February 24, 2015 8:53 AM To: Syniurge/Calypso Cc: wilsonk Subject: Re: [Calypso] parse: allow 'function' keyword to propogate through to Calypso (#5)
Yes C++ identifiers that are keywords in D are broken. If it's just during the parsing we could make a hack for every D keyword not present in D, or maybe force the lexer to read identifiers. Could you look into that and make a more comprehensive hack?
I also got errors with "out" and "in" during the semantic phase yesterday, I was wondering if this has something to do with that are or if it's related to a recent change I made in my tree. Probably the latter (I hope).
— Reply to this email directly or view it on GitHub https://github.com/Syniurge/Calypso/pull/5#issuecomment-75782371 .
Actually it's not only about parsing imports, D code can't use those identifiers at all if they are used by C++ code as symbol names. The mapping will work but they won't be usable.
We need either to change those identifiers to ones available in D, but that's not that easy because ideally we should check for collisions with identifiers already in-use (although there's the same issue with overloaded operator mapping which will need a check like this eventually), or we need to introduce a way to tell the lexer to read a keyword as an identifier, e.g: §function, §out (any cooler character than §?)
I think the second is cleaner especially if more language plugins appear in the future.
Hello Elie,
Yeah, I was looking at this a little today and came to the same conclusion that we would probably need to go all the way back to the lexer, unfortunately. I thought maybe that was the case with ‘function’ also, but when the simple fix I implemented worked I thought maybe we could get away with it :)
I’ll look at the lexer and possibly some sort of pluggable keyword to identifier maps. I like that character as a marker…just don’t know how to produce it?!?! :)
§ … got it, though I have never done that before.
Thanks,
Kelly
From: Elie Morisse [mailto:[email protected]] Sent: Tuesday, February 24, 2015 4:04 PM To: Syniurge/Calypso Cc: wilsonk Subject: Re: [Calypso] parse: allow 'function' keyword to propogate through to Calypso (#5)
Actually it's not only about parsing imports, D code can't use those identifiers at all if they are used by C++ code as symbol names. The mapping will work but they won't be usable.
We need either to change those identifiers to ones available in D, but that's not that easy because ideally we should check for collisions with identifiers already in-use (although there's the same issue with overloaded operator mapping which will need a check like this eventually), or we need to introduce a way to tell the lexer to read a keyword as an identifier, e.g: §function, §out (any cooler character than §?)
I think the second is cleaner especially if more language plugins appear in the future.
— Reply to this email directly or view it on GitHub https://github.com/Syniurge/Calypso/pull/5#issuecomment-75867882 .
Late update: since 7f2aa8bce54cf16c66b64b7b59b78261cc92216c reserved class names are being prefixed with §. I haven't tried to use those identifiers yet though, the lexer may need tweaking to take these § characters.