[Synopsis-cvs] CVS: Synopsis/Synopsis/Parser/C++/occ parse.cc,1.27 ptree.cc,1.7 ptree.h,1.9 token.cc,1.12 token.h,1.5 walker.cc,1.9 walker.h,1.6
Stephen Davies chalky at users.sourceforge.netSun Oct 27 00:24:02 UTC 2002
- Previous message: [Synopsis-cvs] CVS: Synopsis/Synopsis/Parser/C++ emul.py,1.6
- Next message: [Synopsis-cvs] CVS: Synopsis/Synopsis/Parser/C++/regression test.py,1.3
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Update of /cvsroot/synopsis/Synopsis/Synopsis/Parser/C++/occ
In directory usw-pr-cvs1:/tmp/cvs-serv20769/occ
Modified Files:
parse.cc ptree.cc ptree.h token.cc token.h walker.cc walker.h
Log Message:
Typeof support. Generate Function when appropriate. Better emulation support.
Index: token.cc
===================================================================
RCS file: /cvsroot/synopsis/Synopsis/Synopsis/Parser/C++/occ/token.cc,v
retrieving revision 1.9
retrieving revision 1.12
diff -C2 -d -r1.9 -r1.12
*** token.cc 23 Aug 2002 08:30:08 -0000 1.9
--- token.cc 27 Oct 2002 07:23:30 -0000 1.12
***************
*** 79,82 ****
--- 79,86 ----
token_len = 0;
+ // Re-init incase used multiple times by Synopsis
+ comments = nil;
+ user_keywords = nil;
+
InitializeOtherKeywords();
}
***************
*** 770,780 ****
--- 774,789 ----
{ "__asm__", token(ATTRIBUTE) },
{ "__attribute__", token(ATTRIBUTE) },
+ { "__complex__",token(Ignore) },
{ "__const", token(CONST) },
{ "__extension__", token(EXTENSION) },
+ { "__imag__", token(Ignore) },
{ "__inline__", token(INLINE) },
+ { "__real__", token(Ignore) },
{ "__restrict", token(Ignore) },
{ "__restrict__", token(Ignore) },
{ "__signed", token(SIGNED) },
{ "__signed__", token(SIGNED) },
+ { "__typeof", token(TYPEOF) },
+ { "__typeof__", token(TYPEOF) },
#endif
{ "asm", token(ATTRIBUTE) },
Index: walker.cc
===================================================================
RCS file: /cvsroot/synopsis/Synopsis/Synopsis/Parser/C++/occ/walker.cc,v
retrieving revision 1.5
retrieving revision 1.9
diff -C2 -d -r1.5 -r1.9
*** walker.cc 23 May 2001 05:08:47 -0000 1.5
--- walker.cc 27 Oct 2002 07:23:30 -0000 1.9
***************
*** 13,16 ****
--- 13,17 ----
*/
+ #include <iostream>
#include <cstring>
#include "env.h"
***************
*** 1291,1294 ****
--- 1292,1335 ----
}
+ Ptree* Walker::TranslateTypeid(Ptree* exp)
+ {
+ Ptree* e = exp->Second();
+ if(e->Eq('('))
+ e = exp->Third();
+
+ Ptree* e2 = Translate(e);
+ if(e == e2)
+ return exp;
+ else
+ return new PtreeTypeidExpr(exp->First(),
+ Ptree::ShallowSubst(e2, e, exp->Cdr()));
+ }
+
+ void Walker::TypeofTypeid(Ptree* exp, TypeInfo& t)
+ {
+ t.SetInt(); // FIXME: Should be the type_info type (exp->Third()->Second()->GetEncodedType(), env);
+ }
+
+
+ Ptree* Walker::TranslateTypeof(Ptree* exp)
+ {
+ Ptree* e = exp->Second();
+ if(e->Eq('('))
+ e = exp->Third();
+
+ Ptree* e2 = Translate(e);
+ if(e == e2)
+ return exp;
+ else
+ return new PtreeTypeofExpr(exp->First(),
+ Ptree::ShallowSubst(e2, e, exp->Cdr()));
+ }
+
+ void Walker::TypeofTypeof(Ptree* exp, TypeInfo& t)
+ {
+ t.SetInt(); // FIXME: Should be the type_info type (exp->Third()->Second()->GetEncodedType(), env);
+ }
+
+
Ptree* Walker::TranslateNew(Ptree* exp)
{
***************
*** 1643,1646 ****
--- 1684,1740 ----
else
return arglist;
+ }
+
+ //. Helper function to recursively find the first left-most leaf node
+ Ptree* Walker::FindLeftLeaf(Ptree* node, Ptree*& parent)
+ {
+ if (!node || node->IsLeaf()) return node;
+ // Non-leaf node. So find first leafy child
+ Ptree* leaf;
+ while (node) {
+ if (node->Car()) {
+ // There is a child here..
+ if (node->Car()->IsLeaf()) {
+ // And this child is a leaf! return it and set parent
+ parent = node;
+ return node->Car();
+ }
+ if ((leaf = FindLeftLeaf(node->Car(), parent)))
+ // Not a leaf so try recursing on it
+ return leaf;
+ }
+ // No leaves from Car of this node, so try next Cdr
+ node = node->Cdr();
+ }
+ return NULL;
+ }
+
+ //. Node is never the leaf. Instead we traverse the left side of the tree
+ //. until we find a leaf, and change the leaf to be a CommentedLeaf.
+ void Walker::SetLeafComments(Ptree* node, Ptree* comments)
+ {
+ Ptree* parent, *leaf;
+ CommentedLeaf* cleaf;
+
+ // Find leaf
+ leaf = FindLeftLeaf(node, parent);
+
+ // Sanity
+ if (!leaf) { std::cerr << "Warning: Failed to find leaf when trying to add comments." << std::endl;
+ parent->Display2(std::cout);
+ return; }
+
+ if (!(cleaf = dynamic_cast<CommentedLeaf*>(leaf))) {
+ // Must change first child of parent to be a commented leaf
+ Token tk;
+ tk.ptr = leaf->GetPosition();
+ tk.len = leaf->GetLength();
+ cleaf = new (GC) CommentedLeaf(tk, comments);
+ parent->SetCar(cleaf);
+ } else {
+ // Already is a commented leaf, so add the comments to it
+ comments = Ptree::Snoc(cleaf->GetComments(), comments);
+ cleaf->SetComments(comments);
+ }
}
***** Bogus filespec: walker.h,1.6
- Previous message: [Synopsis-cvs] CVS: Synopsis/Synopsis/Parser/C++ emul.py,1.6
- Next message: [Synopsis-cvs] CVS: Synopsis/Synopsis/Parser/C++/regression test.py,1.3
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Synopsis-changes mailing list