X-Received: by 10.50.98.69 with SMTP id eg5mr1491309igb.7.1405652848472; Thu, 17 Jul 2014 20:07:28 -0700 (PDT) X-Received: by 10.182.126.20 with SMTP id mu20mr170obb.33.1405652848125; Thu, 17 Jul 2014 20:07:28 -0700 (PDT) Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!h18no3379300igc.0!news-out.google.com!bp9ni944igb.0!nntp.google.com!h18no1845273igc.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.python Date: Thu, 17 Jul 2014 20:07:27 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=70.196.67.251; posting-account=h3aEwQoAAACiuqX-oR3gvCVFm8lLHoWj NNTP-Posting-Host: 70.196.67.251 References: <6239bcaa-828f-499b-936d-69d022bb94ac@googlegroups.com> <467108ec-19e7-4089-8d5f-53a80244adaf@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: I need an idea for practise! From: Rick Johnson Injection-Date: Fri, 18 Jul 2014 03:07:28 +0000 Content-Type: text/plain; charset=ISO-8859-1 Xref: csiph.com comp.lang.python:74718 On Thursday, July 17, 2014 9:03:40 PM UTC-5, Chris Angelico wrote: > [colorizers] might well be able to *utilize* regexps [...] > but very few modern programming languages can be fully and > correctly defined within the limits of regexp syntax. We're not talking about "defining" or "interpreting" languages Chris, we're simply talking about "colorizers" -- which simply search for lexical patterns and apply *COLOR* to the resulting matches! PAY ATTENTION! > For instance, how can you recognize and thus colorize > assignments differently from name references, to > distinguish between "foo = 1" and "foo == 1"? First of all, why the heck would want to colorize something like that? And if your intention is "highlight" cases where a programmer uses "==" in a condition, then you need to use a "source code analyzer", like Pylint! Secondly, as the number of colorizer targets increases, the effectiveness of colored text decreases -- from a "human comprehension" perspective that is. For me, only the following targets need colorizing: Keywords Built-ins Terminated Strings Un-terminated Strings Comments Annotations That's it! Anymore color and your code starts to resemble a Pollock drip painting. Now, finally, if you cannot write a regexp that matches: 1. One or more alphanumeric chars(or the US) followed by zero or more spaces followed by two equals chars followed by zero or more spaces followed by one or more alphanumeric chars(or the US) or 2. One or more alphanumeric_chars(or the US) followed by zero or more spaces followed by one equals char followed by zero or more spaces, followed by one or more alphanumeric chars(or the US) Then you are either joking or trolling or you need to read the Python re docs. https://docs.python.org/2/library/re.html#module-re