To check a complete python expression use:
def check_open_close(expr):
try:
eval(expr)
except SyntaxError:
return False
else:
return True
This also ignores brackets in quotes, and checks <= & >= operators are
syntatically correct etc...
But is may have side effects... ;-)
eg.
c
On Fri, May 02, 2008 at 03:51:16PM -0700, NevilleDNZ wrote:
> Thanx for the link to these parsers. ANTLR looks interesting.
> Yoyo: http://www-users.cs.york.ac.uk/~fisher/software/yoyovwg/readme
>
> I figured out a way to do it in python.
[...]
>
> def check_open_close(str):
> try:
> eval("
On May 2, 11:13 am, George Sakkis <[EMAIL PROTECTED]> wrote:
> [1]http://en.wikipedia.org/wiki/Context-free_language
> [2]http://en.wikipedia.org/wiki/Regular_language
> [3]http://wiki.python.org/moin/LanguageParsing
Thanx for the link to these parsers. ANTLR looks interesting.
Yoyo: http://www-us
On May 1, 7:44 pm, NevilleDNZ <[EMAIL PROTECTED]> wrote:
> Below is a (flawed) one line RegEx that checks curly brackets (from
> awk/c/python input) are being matched. Is there a one liner for doing
> this in python?
There is not even a 1000-liner regular expression for this; it's a
context-free
On May 2, 9:44 am, NevilleDNZ <[EMAIL PROTECTED]> wrote:
> Below is a (flawed) one line RegEx that checks curly brackets (from
> awk/c/python input) are being matched. Is there a one liner for doing
> this in python?
>
> ThanX
> N
>
> re_open_close="(((\{))[^{}]*((?(0)\})))+"
> re_open_close=re.co