Re: [PATCH] Make checkpatch rant about trailing ; at the end of "if" expr

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Aug 20 2007 13:52, Bodo Eggert wrote:
>> But. The above regex does not seem to handle
>> 
>> if ((a = b));
>> oops;
>> 
>> I have tried to come up with a superduper regex that handles multiple
>> (), but my regex fu seems to stop above two pairs of ().
>
>This is because you can't do that using finite regular expressions.
>
>Regular expressions are Type-3 grammars, but you'd need a Type-2
>grammar to express the Dyck language (and you need to parse a Dyck
>Language, ignoring the non-dyck-parts).

So what about this then...


$s = shift @ARGV;
$r = qr/a(??{ $r })?b/;
if ($s =~ /^$r$/) {
	print "Yup, that's good\n";
} else {
	print "fail\n";
}


$ perl foo.pl aabbbb
Not so much
$ perl foo.pl aaaabbbb
Yup, that's good
$ perl foo.pl aaaaabbbb
Not so much


>-- 
>Your e-mail has been returned due to insufficient voltage. 
>
>Friß, Spammer: [email protected] [email protected]
> [email protected] [email protected]
>-
>To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>the body of a message to [email protected]
>More majordomo info at  http://vger.kernel.org/majordomo-info.html
>Please read the FAQ at  http://www.tux.org/lkml/
>

	Jan
-- 

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux