Chief of Chaos has asked for the wisdom of the Perl Monks concerning the following question:
are not ok :void CLASS1::Function0 (void){ } const void CLASS1::Function1 (void) { } const CLASS2::Type CLASS1::Function3 (void){ } std::vector<std::string>& CLASS1::Function4 (void){ } const CLASS2::Type<Type2>* CLASS1::Function5 (void){ }
etcconst std::string Class1::Member1 = ""; foo = Class2::function(FOO,BAA);
I hope the great spirit of monk wisdom can help a unworthy little apprentice like me.#!/usr/local/bin/perl -w use strict; use warnings; while (<DATA>) { chomp(); my $reg=""; $reg.="^[a-zA-Z0-9]+"; $reg.="\\s*"; $reg.="[^:]*::\\s*"; $reg.="([^ ]*\\s)?"; $reg.="([^(]*)"; $reg.="\\([^)]*\\)[{]?\$"; print "$2\n" if (/$reg/); } __DATA__ void CLASS1::Function0 (void){ } const void CLASS1::Function1 (void) { } const CLASS2::Type CLASS1::Function3 (void){ } std::vector<std::string>& CLASS1::Function4 (void){ } const CLASS2::Type<Type2>* CLASS1::Function5 (void){ } const std::string Class1::Member1 = "" " more data "; std::vector<std::string>& CLASS1::Function4 (void){ foo = Class2::function(FOO,BAA); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: need regex to parse c++ functions
by broquaint (Abbot) on Nov 27, 2002 at 15:41 UTC | |
by Chief of Chaos (Friar) on Nov 28, 2002 at 07:51 UTC | |
|
Re: need regex to parse c++ functions
by Zaxo (Archbishop) on Nov 27, 2002 at 17:36 UTC | |
by Chief of Chaos (Friar) on Nov 28, 2002 at 07:44 UTC |