Contents 
 Index 
 "Perl Program Reference" 
 < Previous 
 Next > 

pl_comment_chg2.pl

Go to the documentation of this file.
00001 // This file has been modified on-the-fly with an input filter
00002 // to change it from Perl syntax to C++ strictly for the purposes
00003 // of faking out Doxygen. Modifications include:
00004 
00005 // - changing local() definitions to C++ #define statements.
00006 // - commenting out undef statements.
00007 // - changing $globe'... variable names to $globe_...
00008 // - changing sub statements to look like C++ functions.
00009 // - changing # comments to C++ comments.
00010 // - ...
00011 
00012 // If you see other strangeness in the HTML version of the Perl file,
00013 // it comes from getting it to look more C++ like.
00014 
00015 
00016 // #!/usr/#define/bin/perl
00017 
00018 //##############################################################################/
00019 //#
00020 /** @file
00021  ** @brief Changes the perl files so that it "looks" like a C file with 
00022  ** respect to the comment format and function names.
00023  ** 
00024  ** This is intended as an input filter to Doxygen.
00025  **
00026  ** @param Input file that uses Perl (hash-hash-bang) comments.
00027  ** @return Output is a file that uses C-style comments required
00028  ** by Doxygen. 
00029  **
00030  ** If a line begins with hash-hash-bang, it is considered part of a Doxygen comment
00031  ** block.
00032  ** Lines that only have hash are turned into // comments and are later ignored
00033  ** by Doxygen.
00034  **  
00035  ** @ingroup tp_tools
00036  **
00037  ** @author Glenn C. Maxey
00038  **/
00039 // #
00040 //# $Id: pl_comment_chg2.pl,v 1.1 2002/06/05 20:17:43 gmaxe Exp $
00041 //#
00042 //# 2002 Created by Voyant Technologies, Inc., Westminster, Colorado, USA.
00043 //#
00044 //# Permission to use, copy, modify, and distribute this software and its 
00045 //# documentation under the terms of the GNU General Public License is hereby 
00046 //# granted. No representations are made about the suitability of this software 
00047 //# for any purpose. It is provided "as is" without express or implied warranty. 
00048 //# See the GNU General Public License (http://www.gnu.org/copyleft/gpl.html) 
00049 //# for more details.
00050 //# 
00051 //# Documents produced by this script are derivative works derived from the 
00052 //# input used in their production; they are not affected by this license.
00053 //#
00054 //# $Log: pl_comment_chg2.pl,v $
00055 //# Revision 1.1  2002/06/05 20:17:43  gmaxe
00056 //# Very similar to the original file, but do not do as much conversion
00057 //# to match C-code. Version 2 tries to enhance the capabilities to handle
00058 //# Voyant perl documentation conventions, whereby function curly braces happen
00059 //# on the next line. Version 3 comments out such conversion efforts and
00060 //# only converts code comments into a form usable by doxygen. This is
00061 //# useful, because mostly only the file header is needed and not information
00062 //# on individual perl functions.
00063 //#
00064 //# Revision 1.7  2002/04/06 01:55:13  gmaxe
00065 //# New files and new general constructs for handling tags. Uses globals better.
00066 //# The html_look* files are designed to handle spider tracing of html systems.
00067 //#
00068 //# Revision 1.6  2002/01/16 19:49:08  gmaxe
00069 //# Removed much of revision history in comments.
00070 //#
00071 //#
00072 //##############################################################################/
00073 
00074 BEGIN {
00075    #define $comment_count  0  //  count if you're in the comments somewhere.
00076 //    print "\/\/ This file has been modified on-the-fly with an input filter\n";
00077 //    print "\/\/ to change it from Perl syntax to C++ strictly for the purposes\n";
00078 //    print "\/\/ of faking out Doxygen. Modifications include:\n\n";
00079    print "\/\/ - changing #define definitions to C++ \// define statements.\n"
00080    print "\/\/ - commenting out // undef statements.\n";
00081 //    print "\/\/ - changing sub statements to look like C++ functions.\n";
00082 //    print "\/\/ - changing \//  comments to C++ comments.\n";
00083 //    print "\/\/ - ...\n\n";
00084 //    print "\/\/ If you see other strangeness in the HTML version of the Perl file,\n";
00085 //    print "\/\/ it comes from getting it to look more C++ like.\n\n\n";
00086 }
00087 
00088 NEW_LINE: while (<>) {
00089 
00090    // ######## 
00091    //  Begin replacement of ##! comments with /** ... **/ comments
00092 //    //  This purposely does not do NEW_LINE or printing.
00093    // ######## 
00094    if (/^\// \#\!/) {
00095       if ($comment_count == 0){
00096          //  first line of a comment block
00097          $comment_count++;
00098          $_ =~ s/\// \#\!/\/\*\*/;
00099       } else {
00100          //  Some line in the middle of a comment block.
00101          $comment_count++;
00102          // ##
00103          //  Changed to have middle stuff with asterix.
00104          //  $_ =~ s/\#\#\!//;
00105          // ##
00106          $_ =~ s/\// \#\!/ \*\*/;
00107       }
00108    } elsif ($comment_count > 0){
00109       //  We were in a comment block; need to terminate it.
00110       $comment_count = 0;
00111       $_ = " \*\*\/\n" . $_ ;
00112    }
00113    // ######## 
00114 //    //  This purposely does not do NEW_LINE or printing.
00115    // ######## 
00116    // ######## End Comment style change.
00117 
00118    // ######## 
00119    //  Begin replacement of # comments with // comments
00120 //    //  This purposely does not do NEW_LINE or printing.
00121    // ######## 
00122    if (/^\// \!/) {
00123       //  Take care of the first line in a perl file.
00124       $_ =~ s/\// \!/\/\/ \#\!/;
00125    } elsif (/^[\// ]/) {
00126       //  Take care of lines that begin with a # perl comment
00127       $_ =~ s/\// /\/\//;
00128    } elsif (/[\// ]/) {
00129       //  Take care of lines that have a # perl comment somewhere
00130       $_ =~ s/\// /\/\/ /;
00131    }
00132    // ######## 
00133 //    //  This purposely does not do NEW_LINE or printing.
00134    // ########
00135    if (/globe\'/){
00136       $_ =~ s/globe\'/globe\_/g;
00137    }
00138    // ######## End Comment style change.
00139 
00140    // ######## 
00141    //  Begin replacement of perl specific constructs
00142    // ######## 
00143    if /#define/ {
00144       //  print "\/\/\! Changed from \"#define\" definition to \"\#define\" for Doxygen.\n"
00145 //       //  print "\/\/\! $_\n";
00146       //  $_ ~ s/#define/\#define/
00147       $_ =~ s/\(//;
00148       $_ =~ s/\)//;
00149       $_ =~ s/\=//;
00150       //  $_ =~ s/\;//;
00151 //       print $_;
00152       next NEW_LINE;
00153    }
00154    if (/// undef/) {
00155       $_ =~ s/// undef/\/\/ undef/;
00156 //       print $_;
00157       next NEW_LINE;
00158    }
00159    
00160    if ((/^sub/) && (/\{/)) {
00161       $_ =~ s/\{/ \( \) \{/;
00162       $_ =~ s/sub/int/;
00163 //       print $_;
00164       next NEW_LINE;
00165    } elsif (/^sub/) {
00166       $_ =~ s/sub/int/;
00167       $_ =~ s/\n//;
00168 //       print "$_ \( \)\n";
00169       next NEW_LINE;
00170    }
00171    
00172    if ((/^\{/) && (/main/)) {
00173 //       print "int main $_";
00174       next NEW_LINE;
00175    }
00176    
00177 if (1){   
00178 //    if (/(print|exit|close)/) {
00179 // //   if (/^(print|while|if|close|unless|exit)/) {
00180       //  Then it is not really a function
00181 // //      print "\/\/ The following isn't really commented out; Doxygen fake-out.\n";
00182 //       print "\/\/ ";
00183 //       print $_;
00184       next NEW_LINE;
00185    }
00186 }
00187    // ######## 
00188 
00189 
00190    // ######## 
00191    //  Begin replacement of @lim or @lim to @lim
00192    // ######## 
00193    if (/\@lim|\@lim/) {
00194       $_ =~ s/\@lim/\@lim/;
00195       $_ =~ s/\@lim/\@lim/;
00196 //       print $_;
00197       next NEW_LINE;
00198    } 
00199    
00200    // ######## 
00201    //  Default Fall through
00202    // ######## 
00203 //    print $_;
00204 
00205 }  
00206 
00207 
00208 
00209 
00210 
00211 
00212 
00213 
00214 


 "Perl Program Reference" 
 < Previous 
 Next > 


Open-Source tools compliments of Voyant Technologies, Inc. and Glenn C. Maxey.
01/13/2003

TP Tools v2-00-0a

# tpt-perl-hcr-02