[Synopsis-changes] Synopsis/Synopsis/Synopsis/Parsers/Cxx/syn ast.cc,1.19,1.20 ast.hh,1.23,1.24 builder.cc,1.44,1.45 builder.hh,1.32,1.33 dumper.cc,1.23,1.24 dumper.hh,1.15,1.16 synopsis.cc,1.49,1.50 synopsis.hh,1.32,1.33

Stefan Seefeld stefan at synopsis.fresco.org
Tue Dec 2 05:45:54 UTC 2003


Update of /cvs/synopsis/Synopsis/Synopsis/Parsers/Cxx/syn
In directory frida:/tmp/cvs-serv30814/Synopsis/Parsers/Cxx/syn

Modified Files:
	ast.cc ast.hh builder.cc builder.hh dumper.cc dumper.hh 
	synopsis.cc synopsis.hh 
Log Message:
generate Builtin 'end of scope' instead of Declaration 'dummy'

Index: ast.cc
===================================================================
RCS file: /cvs/synopsis/Synopsis/Synopsis/Parsers/Cxx/syn/ast.cc,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -p -d -r1.19 -r1.20
--- ast.cc	27 Jan 2003 06:53:36 -0000	1.19
+++ ast.cc	2 Dec 2003 05:45:51 -0000	1.20
@@ -22,6 +22,9 @@
 // 02111-1307, USA.
 
 // $Log$
+// Revision 1.20  2003/12/02 05:45:51  stefan
+// generate Builtin 'end of scope' instead of Declaration 'dummy'
+//
 // Revision 1.19  2003/01/27 06:53:36  chalky
 // Added macro support for C++.
 //
@@ -100,6 +103,23 @@ Declaration::declared()
 }
 
 //
+// AST::Builtin
+//
+
+Builtin::Builtin(SourceFile* file, int line, const std::string &type, const ScopedName& name)
+    : Declaration(file, line, type, name)
+{ }
+
+Builtin::~Builtin()
+{ }
+
+void
+Builtin::accept(Visitor* visitor)
+{
+    visitor->visit_builtin(this);
+}
+
+//
 // AST::Macro
 //
 
@@ -357,6 +377,10 @@ Visitor::~Visitor()
 {}
 void Visitor::visit_declaration(Declaration*)
 {}
+
+void Visitor::visit_builtin(Builtin*)
+{}
+
 void Visitor::visit_macro(Macro* d)
 {
     visit_declaration(d);

Index: ast.hh
===================================================================
RCS file: /cvs/synopsis/Synopsis/Synopsis/Parsers/Cxx/syn/ast.hh,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -p -d -r1.23 -r1.24
--- ast.hh	11 Nov 2003 06:01:45 -0000	1.23
+++ ast.hh	2 Dec 2003 05:45:51 -0000	1.24
@@ -399,6 +399,20 @@ private:
     Include::vector m_includes;
 };
 
+//. A Builtin is a node to be used internally.
+//. Right now it's being used to capture comments
+//. at the end of a scope.
+class Builtin : public Declaration
+{
+public:
+    Builtin(SourceFile* file, int line, const std::string &type, const ScopedName& name);
+
+    //. Destructor
+    virtual ~Builtin();
+
+    //. Accepts the given visitor
+    virtual void accept(Visitor*);
+};
 
 //. Encapsulates a preprocessor macro. Macros are stored in the AST, but since
 //. they are not regular C++ syntax they are treated specially: They will be
@@ -987,6 +1001,7 @@ public:
     // Abstract destructor makes the class abstract
     virtual ~Visitor() = 0;
     virtual void visit_declaration(Declaration*);
+    virtual void visit_builtin(Builtin*);
     virtual void visit_macro(Macro*);
     virtual void visit_scope(Scope*);
     virtual void visit_namespace(Namespace*);

Index: builder.cc
===================================================================
RCS file: /cvs/synopsis/Synopsis/Synopsis/Parsers/Cxx/syn/builder.cc,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -p -d -r1.44 -r1.45
--- builder.cc	27 Jan 2003 06:53:37 -0000	1.44
+++ builder.cc	2 Dec 2003 05:45:51 -0000	1.45
@@ -22,6 +22,9 @@
 // 02111-1307, USA.
 
 // $Log$
+// Revision 1.45  2003/12/02 05:45:51  stefan
+// generate Builtin 'end of scope' instead of Declaration 'dummy'
+//
 // Revision 1.44  2003/01/27 06:53:37  chalky
 // Added macro support for C++.
 //
@@ -658,13 +661,13 @@ AST::Enum* Builder::add_enum(int line, c
 }
 
 //. Add tail comment
-AST::Declaration* Builder::add_tail_comment(int line)
+AST::Builtin *Builder::add_tail_comment(int line)
 {
     ScopedName name;
-    name.push_back("dummy");
-    AST::Declaration* decl = new AST::Declaration(m_file, line, "dummy", name);
-    add(decl);
-    return decl;
+    name.push_back("EOS");
+    AST::Builtin *builtin = new AST::Builtin(m_file, line, "EOS", name);
+    add(builtin);
+    return builtin;
 }
 
 // A functor that adds only inheritances which are class objects to a given

Index: builder.hh
===================================================================
RCS file: /cvs/synopsis/Synopsis/Synopsis/Parsers/Cxx/syn/builder.hh,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -p -d -r1.32 -r1.33
--- builder.hh	27 Jan 2003 06:53:37 -0000	1.32
+++ builder.hh	2 Dec 2003 05:45:51 -0000	1.33
@@ -199,9 +199,8 @@ public:
     //. Add an enum
     AST::Enum* add_enum(int, const std::string& name, const AST::Enumerator::vector &);
 
-    //. Add a tail comment. This will be a dummy declaration with an empty name
-    //. and type "dummy"
-    AST::Declaration* add_tail_comment(int line);
+    //. Add a tail comment. This will be a builtin with name 'EOS'
+    AST::Builtin *add_tail_comment(int line);
 
     //
     // Using methods

Index: dumper.cc
===================================================================
RCS file: /cvs/synopsis/Synopsis/Synopsis/Parsers/Cxx/syn/dumper.cc,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -p -d -r1.23 -r1.24
--- dumper.cc	27 Jan 2003 06:53:37 -0000	1.23
+++ dumper.cc	2 Dec 2003 05:45:51 -0000	1.24
@@ -22,6 +22,9 @@
 // 02111-1307, USA.
 
 // $Log$
+// Revision 1.24  2003/12/02 05:45:51  stefan
+// generate Builtin 'end of scope' instead of Declaration 'dummy'
+//
 // Revision 1.23  2003/01/27 06:53:37  chalky
 // Added macro support for C++.
 //
@@ -293,9 +296,13 @@ std::string Dumper::formatParam(AST::Par
 void Dumper::visit_declaration(AST::Declaration* decl)
 {
     visit(decl->comments());
-    if (decl->type() == "dummy")
-        return;
     std::cout << m_indent_string << "DECL " << decl->name() << std::endl;
+}
+
+void Dumper::visit_builtin(AST::Builtin *builtin)
+{
+    visit(builtin->comments());
+    std::cout << m_indent_string << "BUILTIN " << builtin->name() << std::endl;
 }
 
 void Dumper::visit_macro(AST::Macro* macro)

Index: dumper.hh
===================================================================
RCS file: /cvs/synopsis/Synopsis/Synopsis/Parsers/Cxx/syn/dumper.hh,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -p -d -r1.15 -r1.16
--- dumper.hh	27 Jan 2003 06:53:37 -0000	1.15
+++ dumper.hh	2 Dec 2003 05:45:51 -0000	1.16
@@ -87,6 +87,7 @@ public:
     void visit(const std::vector<AST::Comment*>&);
     virtual void visit_macro(AST::Macro*);
     virtual void visit_declaration(AST::Declaration*);
+    virtual void visit_builtin(AST::Builtin*);
     virtual void visit_scope(AST::Scope*);
     virtual void visit_namespace(AST::Namespace*);
     virtual void visit_forward(AST::Forward*);

Index: synopsis.cc
===================================================================
RCS file: /cvs/synopsis/Synopsis/Synopsis/Parsers/Cxx/syn/synopsis.cc,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -p -d -r1.49 -r1.50
--- synopsis.cc	11 Nov 2003 06:01:45 -0000	1.49
+++ synopsis.cc	2 Dec 2003 05:45:51 -0000	1.50
@@ -23,6 +23,9 @@
 // 02111-1307, USA.
 
 // $Log$
+// Revision 1.50  2003/12/02 05:45:51  stefan
+// generate Builtin 'end of scope' instead of Declaration 'dummy'
+//
 // Revision 1.49  2003/11/11 06:01:45  stefan
 // adjust to directory/package layout changes
 //
@@ -663,6 +666,21 @@ PyObject *Synopsis::Declaration(AST::Dec
     return pydecl;
 }
 
+PyObject *Synopsis::Builtin(AST::Builtin* decl)
+{
+    Trace trace("Synopsis::Builtin");
+    PyObject *pybuiltin, *file, *type, *name;
+    pybuiltin = PyObject_CallMethod(m_ast, "Builtin", "OiOOO",
+	    file = m->py(decl->file()), decl->line(), m->cxx(),
+	    type = m->py(decl->type()), name = m->Tuple(decl->name()));
+    assertObject(pybuiltin);
+    addComments(pybuiltin, decl);
+    Py_DECREF(file);
+    Py_DECREF(type);
+    Py_DECREF(name);
+    return pybuiltin;
+}
+
 PyObject *Synopsis::Macro(AST::Macro* decl)
 {
     Trace trace("Synopsis::Macro");
@@ -976,6 +994,11 @@ void Synopsis::visit_declaration(AST::De
     // Assume this is a dummy declaration
     if (m_filter->should_store(decl))
         m->add(decl, Declaration(decl));
+}
+void Synopsis::visit_builtin(AST::Builtin* decl)
+{
+    if (m_filter->should_store(decl))
+	m->add(decl, Builtin(decl));
 }
 void Synopsis::visit_macro(AST::Macro* decl)
 {

Index: synopsis.hh
===================================================================
RCS file: /cvs/synopsis/Synopsis/Synopsis/Parsers/Cxx/syn/synopsis.hh,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -p -d -r1.32 -r1.33
--- synopsis.hh	27 Jan 2003 06:53:37 -0000	1.32
+++ synopsis.hh	2 Dec 2003 05:45:51 -0000	1.33
@@ -105,6 +105,7 @@ public:
     PyObject* SourceFile(AST::SourceFile*);
     PyObject* Include(AST::Include*);
     PyObject* Declaration(AST::Declaration*);
+    PyObject* Builtin(AST::Builtin*);
     PyObject* Macro(AST::Macro*);
     PyObject* Forward(AST::Forward*);
     PyObject* Scope(AST::Scope*);
@@ -125,6 +126,7 @@ public:
     // AST::Visitor methods
     //
     void visit_declaration(AST::Declaration*);
+    void visit_builtin(AST::Builtin*);
     void visit_macro(AST::Macro*);
     void visit_scope(AST::Scope*);
     void visit_namespace(AST::Namespace*);





More information about the Synopsis-changes mailing list