|
|
|
|
|
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 /** @file 00020 ** @brief Input filter for Doxygen for most IVE code files. 00021 ** 00022 ** This "fakes-out" Doxygen into thinking that IVE (Pascal-like) code files 00023 ** are really C files. 00024 ** 00025 ** @param Input source file. 00026 ** @return Output is file with changes. 00027 ** 00028 ** @ingroup tp_tools tp_dox 00029 ** 00030 ** @author Glenn C. Maxey 00031 **/ 00032 // // 00033 //// $Id: dox_ive_filter.pl,v 1.6 2002/01/16 19:49:08 gmaxe Exp $ 00034 //// 00035 //// 2002 Created by Voyant Technologies, Inc., Westminster, Colorado, USA. 00036 //// 00037 //// Permission to use, copy, modify, and distribute this software and its 00038 //// documentation under the terms of the GNU General Public License is hereby 00039 //// granted. No representations are made about the suitability of this software 00040 //// for any purpose. It is provided "as is" without express or implied warranty. 00041 //// See the GNU General Public License (http://www.gnu.org/copyleft/gpl.html) 00042 //// for more details. 00043 //// 00044 //// Documents produced by this script are derivative works derived from the 00045 //// input used in their production; they are not affected by this license. 00046 //// 00047 //// $Log: dox_ive_filter.pl,v $ 00048 //// Revision 1.6 2002/01/16 19:49:08 gmaxe 00049 //// Removed much of revision history in comments. 00050 //// 00051 //// Revision 1.5 2002/01/03 00:25:07 gmaxe 00052 //// Changed the license agreement. 00053 //// 00054 ///////////////////////////////////////////////////////////////////////////////// 00055 00056 BEGIN { 00057 $inEnum = 0; 00058 $inVar = 0; 00059 $inFunDecl = 0; 00060 $enum_name = "_nothing_"; 00061 // // print "Starting up...\n"; 00062 #define $comment_count 0 // count if you're in the comments somewhere. 00063 } 00064 00065 LINE_IN: while (<>) { 00066 00067 00068 // ######## 00069 // Begin replacement of //! comments with /** ... **/ comments 00070 // // This purposely does not do NEW_LINE or printing. 00071 // ######## 00072 if (/^\/\/\!/) { 00073 if ($comment_count == 0){ 00074 // first line of a comment block 00075 $comment_count++; 00076 $_ =~ s/\/\/\!/\/\*\*/; 00077 } else { 00078 // Some line in the middle of a comment block. 00079 $comment_count++; 00080 // ## 00081 // Changed to have middle stuff with no asterix. 00082 // $_ =~ s/\/\/\!/ \*\*/; 00083 // ## 00084 $_ =~ s/\/\/\!//; 00085 } 00086 } elsif ($comment_count > 0){ 00087 // We were in a comment block; need to terminate it. 00088 $comment_count = 0; 00089 $_ = " \*\*\/\n" . $_ ; 00090 } 00091 // ######## End Comment style change. 00092 00093 00094 // ######## 00095 // Begin comment out var's 00096 // need to know whether or not a function declaration is being made 00097 // ######## 00098 if ((/^function/) || (/^vfunction/) || (/^xfunction/)) { 00099 if (/\)[\s]*\;/) { 00100 // function declaration begins and ends on this line 00101 // it's really a prototype 00102 $inFunDecl = 0; 00103 } elsif (/\)[\s]*\n/) { 00104 // function declaration ends on this line 00105 $inFunDecl = 1; 00106 } else { 00107 // declaration may end on another line 00108 $inFunDecl = 1; 00109 } 00110 // print $_; 00111 next LINE_IN; 00112 } 00113 00114 if (($inFunDecl) && (/\)[\s]*\;/)) { 00115 // function declaration begins and ends on this line 00116 // it's really a prototype 00117 $inFunDecl = 0; 00118 // print $_; 00119 next LINE_IN; 00120 } 00121 00122 if (($inFunDecl) && ( /\)/ )) { 00123 // function declaration began on another line and ends on this line 00124 // need to remember that a declaration was started 00125 $inFunDecl = 1; 00126 // print $_; 00127 next LINE_IN; 00128 } 00129 00130 // Variables are handled differently 00131 if (($inFunDecl) && (/^var[\s]*/)) { 00132 $inVar = 1; 00133 $inFunDecl = 0; 00134 // print "\/\/\+\+ $_"; 00135 next LINE_IN; 00136 } 00137 00138 if (($inFunDecl) && (/^begin[\s]*/) ) { 00139 $inVar = 0; 00140 $inFunDecl = 0; 00141 // // print "; \/\/\+\+ turns into C++ prototype; not needed in IVE\n{ \/\/\+\+ $_"; 00142 // print "{ \/\/\+\+ $_"; 00143 next LINE_IN; 00144 } 00145 00146 if (($inVar) && (/^begin[\s]*/) ) { 00147 $inVar = 0; 00148 $inFunDecl = 0; 00149 // // print "; \/\/\+\+ turns into C++ prototype; not needed in IVE\n{ \/\/\+\+ $_"; 00150 // print "{ \/\/\+\+ $_"; 00151 next LINE_IN; 00152 } elsif ($inVar) { 00153 // Comment out any variable lines 00154 // print "\/\/\+\+ $_"; 00155 next LINE_IN; 00156 } 00157 // ######## End comment out var's 00158 00159 // ######## 00160 // Script functions use Pascal-like "begin" and "end" that need to be fixed. 00161 // ######## Begin replacement of "begin/end" 00162 if (/^begin[\s]*/) { 00163 $inVar = 0; 00164 $inFunDecl = 0; 00165 // Convert the IVE "begin" statement into something more C/C++ like. 00166 // // print "{ \/\/\+\+ $_ \/\/ The curly brace is non-standard IVE syntax.\n"; 00167 // // print "; \/\/\+\+ turns into C++ prototype; not needed in IVE\n{ \/\/\+\+ $_"; 00168 // print "{ \/\/\+\+ $_"; 00169 next LINE_IN; 00170 } 00171 if (/^end[\s]*/) { 00172 // Convert the IVE "end" statement into something more C/C++ like. 00173 // // print "} \/\/\+\+ $_ \/\/ The curly brace is non-standard IVE syntax.\n"; 00174 // print "} \/\/\+\+ $_"; 00175 $inVar = 0; 00176 $inFunDecl = 0; 00177 next LINE_IN; 00178 } 00179 // ######## End replacement of "begin/end" 00180 00181 00182 00183 // ######## 00184 // Enumerations are also handled differently if it is a script. 00185 // Reformats the enum call to be more C-like for Doxygen. 00186 // ######## Begin Enum 00187 if (/^enum[ \t]+[a-zA-Z][a-zA-Z0-9_]*[ \t]*$/) { 00188 $enum_name = $_; // remember the enumeration name for later 00189 $enum_name =~ s/enum//; 00190 $enum_name =~ s/\s//g; 00191 $inEnum = 1; 00192 // Doxygen comments begin 00193 // print "\/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\/"; 00194 // print "\/\*\* $enum_name is an IVE enumeration. " ; 00195 00196 // print " \*\* \@ingroup s_func" ; 00197 // print " \*\*\/"; 00198 // print " \/\/ If you are reading this in the online HTML system,"; 00199 // print " \/\/ note that syntax is NOT the exact IVE syntax."; 00200 // print "\/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\/"; 00201 // Doxygen comments end 00202 00203 // Enum Prototype Definition begin 00204 // print "typedef enum\n{"; 00205 next LINE_IN; 00206 } 00207 if (($inEnum) && (/^[ \t]*[a-zA-Z][a-zA-Z0-9_]*[ \t]*$/)) { 00208 // print $_; 00209 next LINE_IN; 00210 } 00211 00212 if (($inEnum) && (/^[ \t]*[a-zA-Z][a-zA-Z0-9_]*[ \t]+=[ \t]+-*[0-9]+[ \t]*$/)) { 00213 // print $_; 00214 next LINE_IN; 00215 } 00216 00217 if (($inEnum) && (/^endenum;[ \t]*$/)) { 00218 // print "}\n$enum_name;\n"; 00219 $enum_name = "_nothing_"; // reset the enumeration name 00220 $inEnum = 0; 00221 next LINE_IN; 00222 } 00223 // ######## End Enum 00224 00225 00226 00227 // ######## 00228 // Begin replacement of @lim or @lim to @lim 00229 // ######## 00230 if (/\@lim|\@lim/) { 00231 $_ =~ s/\@lim/\@lim/; 00232 $_ =~ s/\@lim/\@lim/; 00233 // print $_; 00234 next LINE_IN; 00235 } 00236 // ######## End replacement of @lim or @lim to @lim 00237 00238 00239 // ######## Default fall through 00240 // print $_; 00241 00242 } // end of while loop 00243 00244 00245
|
|
|
Open-Source tools compliments of Voyant Technologies, Inc. and Glenn C. Maxey.
01/13/2003
TP Tools v2-00-0a
# tpt-perl-hcr-02