Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #83625 > unrolled thread

Re: Python 3 regex?

Started byIan <hobson42@gmail.com>
First post2015-01-12 19:48 +0000
Last post2015-01-14 21:08 -0800
Articles 3 on this page of 23 — 11 participants

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Python 3 regex? Ian <hobson42@gmail.com> - 2015-01-12 19:48 +0000
    Re: Python 3 regex? Rick Johnson <rantingrickjohnson@gmail.com> - 2015-01-12 15:47 -0800
      Re: Python 3 regex? Chris Angelico <rosuav@gmail.com> - 2015-01-13 10:52 +1100
      Re: Python 3 regex? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-01-13 01:54 +0000
        Re: Python 3 regex? Rick Johnson <rantingrickjohnson@gmail.com> - 2015-01-12 18:53 -0800
          Re: Python 3 regex? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-01-13 05:34 +0000
            Re: Python 3 regex? Rick Johnson <rantingrickjohnson@gmail.com> - 2015-01-13 08:01 -0800
          Re: Python 3 regex? wxjmfauth@gmail.com - 2015-01-13 11:19 -0800
            Re: Python 3 regex? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-01-14 14:02 +0100
              Re: Python 3 regex? alister <alister.nospam.ware@ntlworld.com> - 2015-01-14 15:11 +0000
                Re: Python 3 regex? wxjmfauth@gmail.com - 2015-01-14 10:10 -0800
              Re: Python 3 regex? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-01-15 11:33 +1100
                Re: Python 3 regex? wxjmfauth@gmail.com - 2015-01-14 23:03 -0800
                  Re: Python 3 regex? wxjmfauth@gmail.com - 2015-01-15 00:19 -0800
                Re: Python 3 regex? wxjmfauth@gmail.com - 2015-01-15 04:49 -0800
      Re: Python 3 regex? Steven D'Aprano <steve@pearwood.info> - 2015-01-13 06:39 +0000
        Re: Python 3 regex? Rick Johnson <rantingrickjohnson@gmail.com> - 2015-01-13 09:09 -0800
          Re: Python 3 regex? Rick Johnson <rantingrickjohnson@gmail.com> - 2015-01-13 10:17 -0800
    Re: Python 3 regex? Steven D'Aprano <steve@pearwood.info> - 2015-01-13 04:36 +0000
      Re: Python 3 regex? alister <alister.nospam.ware@ntlworld.com> - 2015-01-13 13:23 +0000
        Re: Python 3 regex? Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2015-01-13 15:58 +0200
      Re: Python 3 regex? Rustom Mody <rustompmody@gmail.com> - 2015-01-14 21:03 -0800
      Re: Python 3 regex? Rustom Mody <rustompmody@gmail.com> - 2015-01-14 21:08 -0800

Page 2 of 2 — ← Prev page 1 [2]


#83691

FromJussi Piitulainen <jpiitula@ling.helsinki.fi>
Date2015-01-13 15:58 +0200
Message-ID<qotbnm2wznw.fsf@ruuvi.it.helsinki.fi>
In reply to#83688
alister <alister.nospam.ware@ntlworld.com> writes:

> On Tue, 13 Jan 2015 04:36:38 +0000, Steven D'Aprano wrote:
> 
> > On Mon, 12 Jan 2015 19:48:18 +0000, Ian wrote:
> > 
> >> My recommendation would be to write a recursive decent parser for
> >> your files.
> >> 
> >> That way will be easier to write,
> > 
> > I know that writing parsers is a solved problem in computer
> > science, and that doing so is allegedly one of the more trivial
> > things computer scientists are supposed to be able to do, but the
> > learning curve to write parsers is if anything even higher than
> > the learning curve to write a regex.
> > 
> > I wish that Python made it as easy to use EBNF to write a parser as it
> > makes to use a regex :-(
> > 
> > http://en.wikipedia.org/wiki/Extended_Backus–Naur_Form
> 
> I would not say that writing parsers is a solved problem.  there may
> be solutions for a number of specific cases but many cases still
> cause difficulty, as an example I do not think there is a 100%
> complete parser for English (even native English speakers don't
> always get it)

There is no complete characterization of English as a set of character
strings, nor will there ever be. Linguists have a slogan for this: All
Grammars Leak. (They used to write formal grammars to characterize
"all and only the well-formed sentences" of a language, or to capture
"necessary and sufficient conditions", and those grammars turned out
to both "over-generate" and "under-generate".)

Ambiguity doesn't help. In practice, it's not enough to find a parse.
One wants a contextually appropriate parse. Sometimes this requires
genuine understanding and knowledge. Also in practice, one may not be
in the business of rejecting ill-formed sentences: one wants to make
partial sense of even those. So, no, never 100 percent complete or 100
percent correct :)

The solved problem is the unambiguous parsing of formal languages that
are defined by a formal grammar to begin with, like the configuration
file format at hand.

[toc] | [prev] | [next] | [standalone]


#83790

FromRustom Mody <rustompmody@gmail.com>
Date2015-01-14 21:03 -0800
Message-ID<ddac1678-c1fe-4bab-b31d-fe38b88381af@googlegroups.com>
In reply to#83656
On Tuesday, January 13, 2015 at 10:06:50 AM UTC+5:30, Steven D'Aprano wrote:
> On Mon, 12 Jan 2015 19:48:18 +0000, Ian wrote:
> 
> > My recommendation would be to write a recursive decent parser for your
> > files.
> > 
> > That way will be easier to write,
> 
> I know that writing parsers is a solved problem in computer science, and 
> that doing so is allegedly one of the more trivial things computer 
> scientists are supposed to be able to do, but the learning curve to write 
> parsers is if anything even higher than the learning curve to write a 
> regex.
> 
> I wish that Python made it as easy to use EBNF to write a parser as it 
> makes to use a regex :-(
> 
> http://en.wikipedia.org/wiki/Extended_Backus-Naur_Form
> 
> 
> 
> -- 
> Steven

There appears to be at least one python package for this
https://pypi.python.org/pypi/iscconf

And for those wanting to use regexes to parse CFGs, the requried
reading is:

http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags

[toc] | [prev] | [next] | [standalone]


#83791

FromRustom Mody <rustompmody@gmail.com>
Date2015-01-14 21:08 -0800
Message-ID<9d34b06a-3393-4b42-8ba6-734c3b9452a6@googlegroups.com>
In reply to#83656
On Tuesday, January 13, 2015 at 10:06:50 AM UTC+5:30, Steven D'Aprano wrote:
> On Mon, 12 Jan 2015 19:48:18 +0000, Ian wrote:
> 
> > My recommendation would be to write a recursive decent parser for your
> > files.
> > 
> > That way will be easier to write,
> 
> I know that writing parsers is a solved problem in computer science, and 
> that doing so is allegedly one of the more trivial things computer 
> scientists are supposed to be able to do, 

"Solved-CS-problem" often is showing that the problem is 
unsolvable :-)

http://blog.reverberate.org/2013/08/parsing-c-is-literally-undecidable.html

[toc] | [prev] | [standalone]


Page 2 of 2 — ← Prev page 1 [2]

Back to top | Article view | comp.lang.python


csiph-web