Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'suppose': 0.05; 'received:verizon.net': 0.07; 'terry': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'subject:parsing': 0.09; 'output': 0.11; 'wrote:': 0.15; '"("': 0.16; 'false),': 0.16; 'hardcoded': 0.16; 'logic.': 0.16; 'reedy': 0.16; 'true),': 0.16; 'pm,': 0.16; 'jan': 0.19; "haven't": 0.21; 'input': 0.21; 'header:In-Reply- To:1': 0.22; 'pair': 0.23; 'referring': 0.23; 'code': 0.24; 'up.': 0.26; 'sort': 0.28; 'character': 0.28; 'exercise': 0.28; 'lee': 0.28; 'bit': 0.28; 'answered': 0.29; 'thanks': 0.31; 'error': 0.31; 'earlier': 0.32; "i'll": 0.33; 'actually': 0.33; 'to:addr :python-list': 0.34; 'header:X-Complaints-To:1': 0.34; 'header :User-Agent:1': 0.34; '...': 0.34; 'test': 0.34; 'example,': 0.35; 'starting': 0.35; 'define': 0.35; 'response': 0.37; 'but': 0.37; 'could': 0.37; 'received:org': 0.38; 'subject:: ': 0.38; 'cases,': 0.38; 'think': 0.38; 'program,': 0.39; 'should': 0.39; 'header :Mime-Version:1': 0.39; 'to:addr:python.org': 0.39; 'series': 0.66; 'exact': 0.69; 'subjectcharset:utf-8': 0.72; 'xah': 0.84; 'subject:little': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: a little parsing challenge =?UTF-8?B?4pi6?= Date: Tue, 19 Jul 2011 15:09:41 -0400 References: <36037253-086b-4467-a1db-9492d3772e78@r5g2000prf.googlegroups.com> <8085725c-a600-4d64-8533-fd15505f94e1@p12g2000pre.googlegroups.com> <71aa9b11-5f47-4c89-bdbb-0fe4cac844e1@s33g2000prg.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Gmane-NNTP-Posting-Host: pool-74-109-121-73.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.18) Gecko/20110616 Lightning/1.0b2 Thunderbird/3.1.11 In-Reply-To: <71aa9b11-5f47-4c89-bdbb-0fe4cac844e1@s33g2000prg.googlegroups.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 47 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1311102598 news.xs4all.nl 23877 [2001:888:2000:d::a6]:47216 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:9916 On 7/19/2011 2:12 PM, Xah Lee wrote: >> Also, you may have answered this earlier but I'll ask again anyways: Y= ou >> ask for the first mismatched pair, Are you referring to the inner most= >> mismatched, or the outermost? For example, suppose you have this file= : >> >> foo[(])bar >> >> Would the "(" be the first mismatched character or would the "]"? > > yes i haven't been precise. Thanks for brining it up. > > thinking about it now, i think it's a bit hard to define precisely. Then it is hard to code precisely. > My elisp code actually reports the =E2=80=9C)=E2=80=9D, so it's wrong t= oo. LOL This sort of exercise should start with a series of test cases, starting = with the simplest. testpairs =3D ( ('', True), # or whatever you want the OK response to be ('a', True), ('abdsdfdsdff', True), ('()', True), # and so on for each pair of fences ('(', False), # or exact error output wanted (')', False), # and so on The above could be generated programatically from the set of pairs that=20 should be the input to the program, so that the pairs are not hardcoded=20 into the logic. '([)]', ???), =2E.. ) --=20 Terry Jan Reedy