Make checkpatch rant about trailing ; at the end of "if" expr
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 11 lines · Jan Engelhardt
Quoted 8 lines · Andy Whitcroft
Quoted 1 line
+ if ($line =~ /\bif\s*\([^\)]*\)\s*\;/) {
Heh, you are the second person to suggest this check today, do I detect some ripped out hair due to one of these!
I've taken this idea and expanded it to cover if, for and while which can all suffer from this. Using the relative indent to work out which are valid combinations:
Quoted 7 lines
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).
Signature · 4 lines
Your e-mail has been returned due to insufficient voltage. Friß, Spammer: [email protected] [email protected] [email protected] [email protected]
Quoted 5 lines · Bodo Eggert
Quoted 5 lines
But. The above regex does not seem to handle
if ((a = b));
oops;
Quoted 8 lines
Quoted 2 lines
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
Quoted 11 lines
Signature · 9 lines
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
Quoted 16 lines · Jan Engelhardt
Quoted 5 lines · Bodo Eggert
Quoted 5 lines
But. The above regex does not seem to handle
if ((a = b));
oops;Quoted 8 lines
Quoted 2 lines
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).
Quoted 5 lines
So what about this then...
$s = shift @ARGV;
$r = qr/a(??{ $r })?b/;
This is not a regular expression, because it can't be parsed by a finite state machine (DFA/NFA) without a stack.
http://en.wikipedia.org/wiki/Deterministic_finite_state_machine
Obviously perl does allow non-regular expressions.
Quoted 7 lines
if ($s =~ /^$r$/) {
print "Yup, that's good\n";
} else {
print "fail\n";
}Quoted 6 lines
$ perl foo.pl aabbbb Not so much $ perl foo.pl aaaabbbb Yup, that's good $ perl foo.pl aaaaabbbb Not so much
perl foo.pl aaababbb
fail
"$r = qr/a(??{ $r })?b(??{ $r })?/;" does seem to work.
Signature · 3 lines
"Those who would give up essential liberty, to purchase a little temporary safety, deserve neither liberty nor safety." -- Benjamin Franklin, Historical Review of Pennsylvania, 1759
Quoted 17 lines · Bodo Eggert
Quoted 17 lines
Quoted 6 lines
Quoted 6 lines
But. The above regex does not seem to handle
if ((a = b));
oops;Quoted 8 lines
Quoted 2 lines
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...
Quoted 8 lines
Quoted 2 lines
$s = shift @ARGV;
$r = qr/a(??{ $r })?b/;This is not a regular expression, because it can't be parsed by a finite state machine (DFA/NFA) without a stack.
http://en.wikipedia.org/wiki/Deterministic_finite_state_machineObviously perl does allow non-regular expressions.
Exactly, and which is why my idea was to use a (??{ }) block to match if((())); but for some reason, it did not fly, and I do not know either why.
Jan