[PERCEPS] Nested class support

Eric M. Hopper hopper@omnifarious.mn.org
Mon, 25 Oct 1999 07:55:22 -0500


--cmJC7u66zC7hs+87
Content-Type: multipart/mixed; boundary="HlL+5n6rz5pIUxbD"


--HlL+5n6rz5pIUxbD
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: quoted-printable

	I have some quick & dirty hacks to Perceps to make it understand
externally defined nested classes.  By this I mean something like:

class A {
   class nesteda;
};

class A::nesteda {
};

	The distributed version of Perceps currently chokes rather badly
on this.  It decides you are declaring two copies of A.

	I don't think my hack properly handles scoping for the derived
class declarations, but I'm not sure.  I'm not sure if Perceps properly
handles that scoping.  In other words, I'm not sure if Perceps properly
handles all of the following cases, even after my hack:

class A {
   class nestea;
};

class B {
   class nestedba : public nesteda {
   };
   class nestedbb;
};

class B::nestedbb : public A::nesteda {
};

	And, Perceps most definitely does not handle class names with
numbers or underscores.  This is very difficult to fix because of the
constant use of \w+ to match class names.

	I am enclosing the patch for my hack.

Have fun (if at all possible),
--=20
Its name is Public Opinion.  It is held in reverence. It settles everything.
Some think it is the voice of God.  Loyalty to petrified opinion never yet
broke a chain or freed a human soul.     ---Mark Twain
-- Eric Hopper (hopper@omnifarious.mn.org
                http://ehopper-host105.dsl.visi.com/~hopper) --

--HlL+5n6rz5pIUxbD
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="perceps-3.5.0.patch"
Content-Transfer-Encoding: quoted-printable

diff -ru perceps-3.5.0/perceps.pl perceps-3.5.0.1/perceps.pl
--- perceps-3.5.0/perceps.pl	Mon May  3 21:01:31 1999
+++ perceps-3.5.0.1/perceps.pl	Mon Oct 25 07:51:54 1999
@@ -287,7 +287,28 @@
   &PRINT_USAGE;
   exit (0);
 }
-   =20
+
+sub compare_filename {
+    local($aisheader,$bisheader);
+
+    $aisheader =3D ($a =3D~ /^.*(\.(h|hpp|hxx))$/);
+    $bisheader =3D ($b =3D~ /^.*(\.(h|hpp|hxx))$/);
+    if ($aisheader && !$bisheader)
+    {
+	return(-1);
+    }
+    elsif ($bisheader && !$aisheader)
+    {
+	return(1);
+    }
+    else
+    {
+	return $a cmp $b;
+    }
+}
+
+@inputfiles =3D sort compare_filename @inputfiles;
+
 foreach $inputfile (@inputfiles) {
=20
   $sdesc_marker=3D$SDESC_MARKER;
@@ -340,8 +361,6 @@
   &PROCINPUT($fdata[9]);
 } =20
=20
-# foreach $thing (@items) { print "ITEM $thing -> $itype{$thing}\n"; }
-
 @items=3Dgrep(/\w+/,@items);
 @classes=3Dgrep(/\w+/,@classes);
 @gfuncs=3Dgrep(/\w+/,@gfuncs);
@@ -1867,12 +1886,21 @@
   local($echk1,$echk2,$echk3,$echk4,$echkmod,$scnm,$scnmod,$temp,$temp1,$t=
emp2);
   local($temp3,$temp4,$temp5,$locname,$mmem,$newmem,$sttype,@multidef);
   local($ptemp,$haspar,$tempvars,$tempcomm,$fid);
+  local($typeflag);
 #
 #  Extract Data From Class Definition Blocks
 #=20
-         =20
-  if ($block=3D~/^\s*template\s*(\<.+\>)\s+(class|struct|union)\s+(\w+)/) {
+
+  if ($block=3D~/^\s*template\s*(\<.+\>)\s+(class|struct|union)\s+(\w+(\s*=
::\w+)*)/) {
+    local $templatename =3D $1;
+    $typeflag =3D $2;
     $locname=3D$classname=3D$3;
+    if ($classname=3D~/^((\w+\s*::)*\w+)\s*::(\w+)$/) {
+	$classname =3D $3;
+	$nest =3D $1;
+	$memname{$nest,$classname} =3D $classname;
+	$type{$nest,$classname} =3D $typeflag;
+    }
     if ($nest) {
       $classname=3D"${nest}\:\:$classname";
       $container{$classname}=3D$nest;
@@ -1884,13 +1912,20 @@
       if (!$opt_q) { print "	      Will reference duplicate class as $clas=
sname\n"; }
     }
     else { $duplicates{$classname}=3D1; }
-    $template{$classname}=3D"$1";
-    if ($2 eq "class") { $itype{$classname}=3D$CLASS; }
-    if ($2 eq "struct") { $itype{$classname}=3D$STRUCT; }
-    if ($2 eq "union") { $itype{$classname}=3D$UNION; }
+    $template{$classname}=3D"$templatename";
+    if ($typeflag eq "class") { $itype{$classname}=3D$CLASS; }
+    if ($typeflag eq "struct") { $itype{$classname}=3D$STRUCT; }
+    if ($typeflag eq "union") { $itype{$classname}=3D$UNION; }
   }
-  elsif ($block=3D~/^\s*(class|struct|union)\s+(\w+)/) {
+  elsif ($block=3D~/^\s*(class|struct|union)\s+(\w+(\s*::\w+)*)/) {
     $locname=3D$classname=3D$2;
+    $typeflag =3D $1;
+    if ($classname=3D~/^((\w+\s*::)*\w+)\s*::(\w+)$/) {
+	$classname =3D $3;
+	$nest =3D $1;
+	$memname{$nest,$classname} =3D $classname;
+	$type{$nest,$classname} =3D $typeflag;
+    }
     if ($nest) {
       $classname=3D"${nest}\:\:$classname";
       $container{$classname}=3D$nest;
@@ -1902,10 +1937,10 @@
       if (!$opt_q) {  print "	      Will reference duplicate class as $cla=
ssname\n"; }
     }
     else { $duplicates{$classname}=3D1; }
-    if ($1 eq "class") { $itype{$classname}=3D$CLASS; }
-    if ($1 eq "struct") { $itype{$classname}=3D$STRUCT; }
-    if ($1 eq "union") { $itype{$classname}=3D$UNION; }
-    $sttype=3D$1;
+    if ($typeflag eq "class") { $itype{$classname}=3D$CLASS; }
+    if ($typeflag eq "struct") { $itype{$classname}=3D$STRUCT; }
+    if ($typeflag eq "union") { $itype{$classname}=3D$UNION; }
+    $sttype=3D$typeflag;
     if ($block=3D~/\}(\s*|\s*\/\/.*)\s*([\w\s,\[\]]+)\s*;(\s*|\s*\/\/.*)$/=
) {
       if (!($block=3D~/$2\s*;[\s\S]*\}/)) {
         &PROCVAR("$sttype $classname $2\;\n$1\n$3",1,1);
@@ -1993,11 +2028,11 @@
   $modp=3D$parents{$classname};
   $modp=3D~s/<.*>//g;
   foreach (split(",",$modp)) {
-    if (/^\s*(\w|\w[\w\s]*\w)\s+(\w+)\s*$/) {
+    if (/^\s*(\w|\w[\w\s]*\w)\s+(\w+(::\w+)*)\s*$/) {
       $pclasses{$classname}.=3D"$2$;";
       $ihtype{$classname,$2}.=3D"$1";
     }
-    elsif (/(\w+)/) {
+    elsif (/(\w+(::\w+)*)/) {
       $pclasses{$classname}.=3D"$1$;";
       $ihtype{$classname,$1}.=3D"private";
     }
@@ -2016,7 +2051,7 @@
   $block=3D~s/\(([^\)\n]*)\n\s*(\S)([^\)]*)\)/\($1 $2$3\)/g;
=20
   # Remove Constructor-Initializer lists
-  $block=3D~s/($locname\s*[^\{:\;]*)\s*:[^\{\}]*\{/$1\{/g;
+  $block=3D~s/($classname\s*[^\{:\;]*)\s*:[^\{\}]*\{/$1\{/g;
  =20
   # Handle nested classes and unions
   while ($block=3D~/^(\s*)(class|struct|union)([^\<\(\:\{\;]*)([^\(\{\;]*)=
\{/) {

--HlL+5n6rz5pIUxbD
Content-Type: text/plain
Content-Disposition: attachment; filename="my.gpg.key.asc"

-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.0.0 (GNU/Linux)
Comment: For info see http://www.gnupg.org

mQGiBDgPeWMRBADH5HPPhzBYBlL0jfhiPiIMRfW3wP/fix7ZqRztMfzihOvYwllx
XwYTy1THcpuMka5jl7CYaBSecDaapoegDTMxYPWOK5pO9UzCESdo2YrgEW9c7IlD
geQmqGD5SaQoxvEpuw6FM0v5sayVi6fOKAf9B3Y4TIznqvGJ4T4cW+HA5wCg7cMw
A315QtSByeuLnadmgIRPmQkD+wVxFmCbXh8WjjPtJxIbz4iAFDJD0RnqXvho0wn0
sftvD5OdCd4oxU+q7F1xpPFdiJheErcGaVN+/jdOjt7j+clcqbt9EP0OuBheHxjn
Y0aoBsSBDZuTtSCrkjWbzXY2+Dx9knCkZTkbqClSSGx0Fttp373grKMvAYSYSRec
v3USBACylKeJGvSPyYKi6l18mku+AG7zBh+/XKl4vM8iCAX8nFtEXB27778QbU9B
KZQLaeTzYXNYSROnDSViWXVDzyzOT7rVWDsDdtDuhxI7ahvELppU3wwxmpNljXBa
Fi5+RAwucoftmTNLr1+/hLkdYAcS2mEtG4cirluchRFfs7fsbLQ4RXJp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rKSNszQJtnqW+LEs0qE5u+rYW0js2bthfaT4pIR1NGvhcHg11PFc+zh6k7OWRfK
Dc3ih3adi4w2VMAyL1LRYp9w36952izQbr7UCK5kZcVLGDDpkuVDCMxCK1amirib
FBYkcGRzhnPmMbAzW3rWfuYEhVwjnP1hrhVp1YcxJLkpVq5l3Z1yXkWfEVjlSZeV
Yu7eQm8sHZ0rUvYRRCb7rUBYpvewuyB6/LFTPHB+O1pKtKhsdexszO018b1DeUh7
So1jBzqe38qaEIfI+0T/UCfTdpmw1/AmRTb3HPlZ1SsXsODSyqyU2DArnMNAeU0d
mTTqi8MI8pBdIV1RfS1ardL9j4hMBBgRAgAMBQI1cXObBQkFJQqAAAoJEG31xBzq
q6ppi3QAn3yEXUSvlQZxkqyPfxJ/rQCzrVX2AJ9w+omTJ9NYwSJwtrkEDtsqhc76
dw==
=svy+
-----END PGP PUBLIC KEY BLOCK-----

--HlL+5n6rz5pIUxbD--

--cmJC7u66zC7hs+87
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.0 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE4FFM6G4QeWBeRdS8RAoglAJwNbDkimVplftm559lWrBPJyNurpwCgoWqV
pPhNH5tjlBcRXkJMSLdyQ8s=
=9nIA
-----END PGP SIGNATURE-----

--cmJC7u66zC7hs+87--