Perl/Sh parser
Nigel Pearson <[email protected]>
| Newsgroups | gmane.text.doxygen.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi guys. Happy new year!
I am one of the MythTV developers, and some
of us use Doxygen in the project a lot.
The MythTV source code has C, C++, Obj-C,
plus a contrib directory with the usual
assortment of Perl, Shell and Python scripts.
I'm also a Perl hacker from way-back,
and used to use a simple inhouse tool
to generate manpages and HTML from custom
markup in our Perl and Shell scripts.
(this was in the days before POD)
So, I would like to start adding Perl/Sh parsing.
I am lumping these together because they have
similar comment parsing requirements,
and I am hoping that one parser can do both.
A few questions to help give me direction:
1) How do we feel about adding a parser
that just summarises a language
instead of trying to parse every little
feature that they have crammed in there?
(e.g. subroutines and markup instead of
full OO, type matching, blessed modules)
2) I have little idea of where
to start. The structure of the parsers
is a little confusing - I can't work out
how the stuff generated from pyscanner.l
or fortranscanner.l is called, for example.
Any relevant doco, discussion or advice?
3) For a project like MythTV, I don't
want symbols in the scripted stuff to
be references to the compiled stuff.
(e.g. if a Perl script has a usage() routine,
it is in no way related to a C function
which is also named usage() or _usage() )
How does the PHP parser deal with this?
Hacky first steps attached:
% diff -ru doxygen-1.5.4.orig doxygen-1.5.4 >doxy.perl.1.patch
--
Nigel Pearson, [email protected]|"People say I'm strange,
Telstra Net. Eng., Sydney, Australia | does it make me a stranger?
Office: 9202 3900 Fax: 9261 3912 | My best friend was born...
Mobile: 0408 664435 Home: 9792 6998 | in a manger" -DC Talk
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Doxygen-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/doxygen-develop
doxy.perl.1.patch
(application/octet-stream, 3.4 KB)
diff -ru doxygen-1.5.4.orig/src/scanner.l doxygen-1.5.4/src/scanner.l
--- doxygen-1.5.4.orig/src/scanner.l 2007-10-26 21:52:35.000000000 +1000
+++ doxygen-1.5.4/src/scanner.l 2008-01-09 09:46:11.000000000 +1100
@@ -115,6 +115,7 @@
static bool insideObjC = FALSE; //!< processing Objective C code?
static bool insideCli = FALSE; //!< processing C++/CLI code?
static bool insideJS = FALSE; //!< processing JavaScript code?
+static bool insidePerl = FALSE; //!< processing Perl code?
static bool insideCppQuote = FALSE;
static bool insideProtocolList = FALSE;
@@ -332,13 +333,15 @@
insidePHP = langExt==SrcLangExt_PHP;
insideObjC = langExt==SrcLangExt_ObjC;
insideJS = langExt==SrcLangExt_JS;
+ insidePerl = langExt==SrcLangExt_Perl;
if ( insidePHP )
{
useOverrideCommands = TRUE;
}
//printf("setContext(%s) insideIDL=%d insideJava=%d insideCS=%d "
- // "insideD=%d insidePHP=%d insideObjC=%d\n",
- // yyFileName.data(),insideIDL,insideJava,insideCS,insideD,insidePHP,insideObjC
+ // "insideD=%d insidePHP=%d insideObjC=%d insidePerl=%d\n",
+ // yyFileName.data(),insideIDL,insideJava,insideCS,insideD,
+ // insidePHP,insideObjC,insidePerl
// );
}
@@ -604,6 +607,7 @@
%x BitFields
%x FindMembers
%x FindMembersPHP
+%x FindMembersPerl
%x FindMemberName
%x FindFields
%x FindFieldArg
@@ -920,6 +924,9 @@
REJECT;
}
}
+<FindMembersPerl>{B}*"sub"{B}*{LABELID} {
+ printf("Found a Perl Subroutine: %s\n",yytext);
+ }
<CliPropertyType>{ID} {
addType( current );
current->name = yytext;
@@ -5434,6 +5441,10 @@
{
BEGIN( FindMembersPHP );
}
+ else if ( insidePerl )
+ {
+ BEGIN( FindMembersPerl );
+ }
else
{
BEGIN( FindMembers );
diff -ru doxygen-1.5.4.orig/src/util.cpp doxygen-1.5.4/src/util.cpp
--- doxygen-1.5.4.orig/src/util.cpp 2007-10-26 21:33:49.000000000 +1000
+++ doxygen-1.5.4/src/util.cpp 2008-01-09 09:27:43.000000000 +1100
@@ -6158,6 +6158,9 @@
extLookup.insert(".m", new int(SrcLangExt_ObjC));
extLookup.insert(".M", new int(SrcLangExt_ObjC));
extLookup.insert(".mm", new int(SrcLangExt_ObjC));
+ extLookup.insert(".pl", new int(SrcLangExt_Perl));
+ extLookup.insert(".pm", new int(SrcLangExt_Perl));
+ extLookup.insert(".sh", new int(SrcLangExt_Shell));
init=TRUE;
}
if (i!=-1) // name has an extension
diff -ru doxygen-1.5.4.orig/src/util.h doxygen-1.5.4/src/util.h
--- doxygen-1.5.4.orig/src/util.h 2007-08-12 05:45:51.000000000 +1000
+++ doxygen-1.5.4/src/util.h 2008-01-09 09:28:43.000000000 +1100
@@ -85,14 +85,16 @@
enum SrcLangExt
{
- SrcLangExt_IDL = 0x008,
- SrcLangExt_Java = 0x010,
- SrcLangExt_CSharp = 0x020,
- SrcLangExt_D = 0x040,
- SrcLangExt_PHP = 0x080,
- SrcLangExt_ObjC = 0x100,
- SrcLangExt_Cpp = 0x200,
- SrcLangExt_JS = 0x400,
+ SrcLangExt_IDL = 0x0008,
+ SrcLangExt_Java = 0x0010,
+ SrcLangExt_CSharp = 0x0020,
+ SrcLangExt_D = 0x0040,
+ SrcLangExt_PHP = 0x0080,
+ SrcLangExt_ObjC = 0x0100,
+ SrcLangExt_Cpp = 0x0200,
+ SrcLangExt_JS = 0x0400,
+ SrcLangExt_Perl = 0x0800,
+ SrcLangExt_Shell = 0x1000,
};
//--------------------------------------------------------------------