CComment and problem with ctool.so
Bernhard Fischer <[email protected]>
| Newsgroups | gmane.comp.documentation.synopsis |
|---|---|
| Message-ID | <[email protected]> |
Hi Stefan, I'm getting an undefined symbol when trying to use the C parser. Source was checked out 2005-02-19: synopsis -v -d -p C -I. -I../../include -I../../../../include -I../../../../include/asm/mach-default -l CComments -Wp,preprocess,cppflags="' '" -o sdp_advt.syn sdp_advt.h Unable to import Synopsis.Parsers.C.Parser Reason : /opt/local/lib/python2.4/site-packages/Synopsis/Parsers/C/ctool.so: undefined symbol: _ZN8Synopsis5Trace8my_levelE make: *** [sdp_advt.syn] Error 255 Do you have an idea on what i could be doing wrong? The Cxx parser does work, as does the Cpp parser. In __import__, on ImportError, could you please print the reason regardless of verbose mode? PS: Attached is a quick C style comment parser. Before applying it, one should make the intermittent asterisk optional, though.....
synopsis.20050219-2307.diff
(text/plain, 1.8 KB)
diff -X /usr/src/excl -rdup trunk/Synopsis/Processors/Comments/Comments.py /home/cow/tmp/Synopsis/Synopsis/Processors/Comments/Comments.py
--- trunk/Synopsis/Processors/Comments/Comments.py 2005-01-14 00:52:47.000000000 +0100
+++ /home/cow/tmp/Synopsis/Synopsis/Processors/Comments/Comments.py 2005-02-19 22:37:55.000000000 +0100
@@ -84,6 +84,45 @@ class SSDComments(CommentProcessor):
return string.join(self.re_ssd.findall(str),'\n')
+class CComments (CommentProcessor):
+ """A class that formats C89 /* style comments"""
+
+ __re_c = r"/\*[ \t]*(?P<text>.*)(?P<lines>(\n[ \t]*\*.*)*?)(\n[ \t]*)?\*/"
+ __re_line = r"\n[ \t]*\*[ \t]*(?P<text>.*)"
+
+ def __init__(self):
+ "Compiles the regular expressions"
+
+ self.re_c = re.compile(CComments.__re_c)
+ self.re_line = re.compile(CComments.__re_line)
+
+ def visit_comments(self, decl):
+ "Calls process_comment on all comments"
+
+ map(self.process_comment, decl.comments())
+
+ def process_comment(self, comment):
+ """Finds comments in the c format. The format is /* ... */, and
+ it has to cater for all four line forms: "/* ...", " * ...", " */" and
+ the one-line "/* ... */".
+ """
+
+ text = comment.text()
+ text_list = []
+ mo = self.re_c.search(text)
+ while mo:
+ text_list.append(mo.group('text'))
+ lines = mo.group('lines')
+ if lines:
+ mol = self.re_line.search(lines)
+ while mol:
+ text_list.append(mol.group('text'))
+ mol = self.re_line.search(lines, mol.end())
+ mo = self.re_c.search(text, mo.end())
+ text = string.join(text_list,'\n')
+ comment.set_text(text)
+
+
class JavaComments (CommentProcessor):
"""A class that formats java /** style comments"""