lkml.org 
[lkml]   [2007]   [Aug]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] Make checkpatch rant about trailing ; at the end of "if" expr

On Aug 22 2007 11:21, 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/;
>
>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.

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
--
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2007-08-22 11:59    [W:0.050 / U:0.084 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site