|
|
|
|
|
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_chg.pl,v 1.7 2002/04/06 01:55:13 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_chg.pl,v $ 00055 //# Revision 1.7 2002/04/06 01:55:13 gmaxe 00056 //# New files and new general constructs for handling tags. Uses globals better. 00057 //# The html_look* files are designed to handle spider tracing of html systems. 00058 //# 00059 //# Revision 1.6 2002/01/16 19:49:08 gmaxe 00060 //# Removed much of revision history in comments. 00061 //# 00062 //# 00063 //##############################################################################/ 00064 00065 BEGIN { 00066 #define $comment_count 0 // count if you're in the comments somewhere. 00067 // print "\/\/ This file has been modified on-the-fly with an input filter\n"; 00068 // print "\/\/ to change it from Perl syntax to C++ strictly for the purposes\n"; 00069 // print "\/\/ of faking out Doxygen. Modifications include:\n\n"; 00070 print "\/\/ - changing #define definitions to C++ \// define statements.\n" 00071 print "\/\/ - commenting out // undef statements.\n"; 00072 // print "\/\/ - changing \$globe\'... variable names to \$globe_...\n"; 00073 // print "\/\/ - changing sub statements to look like C++ functions.\n"; 00074 // print "\/\/ - changing \// comments to C++ comments.\n"; 00075 // print "\/\/ - ...\n\n"; 00076 // print "\/\/ If you see other strangeness in the HTML version of the Perl file,\n"; 00077 // print "\/\/ it comes from getting it to look more C++ like.\n\n\n"; 00078 } 00079 00080 NEW_LINE: while (<>) { 00081 00082 // ######## 00083 // Begin replacement of ##! comments with /** ... **/ comments 00084 // // This purposely does not do NEW_LINE or printing. 00085 // ######## 00086 if (/^\// \#\!/) { 00087 if ($comment_count == 0){ 00088 // first line of a comment block 00089 $comment_count++; 00090 $_ =~ s/\// \#\!/\/\*\*/; 00091 } else { 00092 // Some line in the middle of a comment block. 00093 $comment_count++; 00094 // ## 00095 // Changed to have middle stuff with asterix. 00096 // $_ =~ s/\#\#\!//; 00097 // ## 00098 $_ =~ s/\// \#\!/ \*\*/; 00099 } 00100 } elsif ($comment_count > 0){ 00101 // We were in a comment block; need to terminate it. 00102 $comment_count = 0; 00103 $_ = " \*\*\/\n" . $_ ; 00104 } 00105 // ######## 00106 // // This purposely does not do NEW_LINE or printing. 00107 // ######## 00108 // ######## End Comment style change. 00109 00110 // ######## 00111 // Begin replacement of # comments with // comments 00112 // // This purposely does not do NEW_LINE or printing. 00113 // ######## 00114 if (/^\// \!/) { 00115 // Take care of the first line in a perl file. 00116 $_ =~ s/\// \!/\/\/ \#\!/; 00117 } elsif (/^[\// ]/) { 00118 // Take care of lines that begin with a # perl comment 00119 $_ =~ s/\// /\/\//; 00120 } elsif (/[\// ]/) { 00121 // Take care of lines that have a # perl comment somewhere 00122 $_ =~ s/\// /\/\/ /; 00123 } 00124 // ######## 00125 // // This purposely does not do NEW_LINE or printing. 00126 // ######## 00127 if (/globe\'/){ 00128 $_ =~ s/globe\'/globe\_/g; 00129 } 00130 // ######## End Comment style change. 00131 00132 // ######## 00133 // Begin replacement of perl specific constructs 00134 // ######## 00135 if /#define/ { 00136 // print "\/\/\! Changed from \"#define\" definition to \"\#define\" for Doxygen.\n" 00137 // // print "\/\/\! $_\n"; 00138 $_ ~ s/#define/\// define/ 00139 $_ =~ s/\(//; 00140 $_ =~ s/\)//; 00141 $_ =~ s/\=//; 00142 $_ =~ s/\;//; 00143 // print $_; 00144 next NEW_LINE; 00145 } 00146 if (/// undef/) { 00147 $_ =~ s/// undef/\/\/ undef/; 00148 // print $_; 00149 next NEW_LINE; 00150 } 00151 if (/^sub/) { 00152 $_ =~ s/\{/ \( \) \{/; 00153 $_ =~ s/sub/int/; 00154 // print $_; 00155 next NEW_LINE; 00156 } 00157 if (1){ 00158 // if (/(print|exit|close)/) { 00159 // // if (/^(print|while|if|close|unless|exit)/) { 00160 // Then it is not really a function 00161 // // print "\/\/ The following isn't really commented out; Doxygen fake-out.\n"; 00162 // print "\/\/ "; 00163 // print $_; 00164 next NEW_LINE; 00165 } 00166 } 00167 // ######## 00168 00169 00170 // ######## 00171 // Begin replacement of @lim or @lim to @lim 00172 // ######## 00173 if (/\@lim|\@lim/) { 00174 $_ =~ s/\@lim/\@lim/; 00175 $_ =~ s/\@lim/\@lim/; 00176 // print $_; 00177 next NEW_LINE; 00178 } 00179 00180 // ######## 00181 // Default Fall through 00182 // ######## 00183 // print $_; 00184 00185 } 00186 00187 00188 00189 00190 00191 00192 00193 00194
|
|
|
Open-Source tools compliments of Voyant Technologies, Inc. and Glenn C. Maxey.
01/13/2003
TP Tools v2-00-0a
# tpt-perl-hcr-02