Re: Python and Regular Expressions

2010-04-12 Thread Neil Cerutti
On 2010-04-11, Steven D'Aprano wrote: > On Sat, 10 Apr 2010 10:11:07 -0700, Patrick Maupin wrote: >> On Apr 10, 11:35??am, Neil Cerutti wrote: >>> On 2010-04-10, Patrick Maupin wrote: >>> > as Pyparsing". ??Which is all well and good, except then the OP will >>> > download pyparsing, take a look

Re: Python and Regular Expressions

2010-04-10 Thread Patrick Maupin
On Apr 10, 1:05 pm, Stefan Behnel wrote: > Running a Python program in CPython eventually boils down to a sequence of > commands being executed by the CPU. That doesn't mean you should write > those commands manually, even if you can. It's perfectly ok to write the > program in Python instead. A

Re: Python and Regular Expressions

2010-04-10 Thread Paul McGuire
On Apr 10, 8:38 pm, Paul Rubin wrote: > The impression that I have (from a distance) is that Pyparsing is a good > interface abstraction with a kludgy and slow implementation.  That the > implementation uses regexps just goes to show how kludgy it is.  One > hopes that someday there will be a more

Re: Python and Regular Expressions

2010-04-10 Thread Paul Rubin
Steven D'Aprano writes: > As entertaining as this is, the analogy is rubbish. Skis are far too > simple to use as an analogy for a parser (he says, having never seen skis > up close in his life *wink*). Have you looked at PyParsing's source code? > Regexes are only a small part of the parser, a

Re: Python and Regular Expressions

2010-04-10 Thread Steven D'Aprano
On Sat, 10 Apr 2010 10:11:07 -0700, Patrick Maupin wrote: > On Apr 10, 11:35 am, Neil Cerutti wrote: >> On 2010-04-10, Patrick Maupin wrote: >> > as Pyparsing".  Which is all well and good, except then the OP will >> > download pyparsing, take a look, realize that it uses regexps under >> > the

Re: Python and Regular Expressions

2010-04-10 Thread Ethan Furman
Stefan Behnel wrote: Patrick Maupin, 10.04.2010 19:11: On Apr 10, 11:35 am, Neil Cerutti wrote: On 2010-04-10, Patrick Maupin wrote: as Pyparsing". Which is all well and good, except then the OP will download pyparsing, take a look, realize that it uses regexps under the hood, and possib

Re: Python and Regular Expressions

2010-04-10 Thread Stefan Behnel
Patrick Maupin, 10.04.2010 19:11: On Apr 10, 11:35 am, Neil Cerutti wrote: On 2010-04-10, Patrick Maupin wrote: as Pyparsing". Which is all well and good, except then the OP will download pyparsing, take a look, realize that it uses regexps under the hood, and possibly be very confused. I

Re: Python and Regular Expressions

2010-04-10 Thread Patrick Maupin
On Apr 10, 11:35 am, Neil Cerutti wrote: > On 2010-04-10, Patrick Maupin wrote: > > as Pyparsing".  Which is all well and good, except then the OP > > will download pyparsing, take a look, realize that it uses > > regexps under the hood, and possibly be very confused. > > I don't agree with that.

Re: Python and Regular Expressions

2010-04-10 Thread Neil Cerutti
On 2010-04-10, Patrick Maupin wrote: > Trust me, I already knew that. But what you just wrote is a > much more useful thing to tell the OP than "Every time someone > tries to parse nested structures using regular expressions, > Jamie Zawinski kills a puppy" which is what I was responding > to. A

Re: Python and Regular Expressions

2010-04-10 Thread Patrick Maupin
On Apr 8, 5:13 am, Nobody wrote: > On Wed, 07 Apr 2010 18:25:36 -0700, Patrick Maupin wrote: > >> Regular expressions != Parsers > > > True, but lots of parsers *use* regular expressions in their > > tokenizers.  In fact, if you have a pure Python parser, you can often > > get huge performance gai

Re: Python and Regular Expressions

2010-04-10 Thread Neil Cerutti
On 2010-04-08, Richard Lamboj wrote: > If someone knows good links to this thema, or can explain how > parsers should/could work, please post it, or explain it. > > Thanks for the Informations and the Help! I liked Crenshaw's "Let's Build a Compiler!". It's pretty trivial to convert his Pascal to

Re: Python and Regular Expressions

2010-04-08 Thread Charles
"Nobody" wrote in message news:pan.2010.04.08.10.12.59.594...@nowhere.com... > On Wed, 07 Apr 2010 18:25:36 -0700, Patrick Maupin wrote: > >>> Regular expressions != Parsers >> >> True, but lots of parsers *use* regular expressions in their >> tokenizers. In fact, if you have a pure Python pars

Re: Python and Regular Expressions

2010-04-08 Thread Richard Lamboj
At the moment i have less time, so its painful to read about parsing, but it is quite interessting. I have taken a look at the different Parsing Modules and i'am reading the Source Code to understand how they Work. Since Yesterday i'am writing on my own small Engine - Just for Fun and understa

Re: Python and Regular Expressions

2010-04-08 Thread Nobody
On Wed, 07 Apr 2010 18:25:36 -0700, Patrick Maupin wrote: >> Regular expressions != Parsers > > True, but lots of parsers *use* regular expressions in their > tokenizers. In fact, if you have a pure Python parser, you can often > get huge performance gains by rearranging your code slightly so th

Re: Python and Regular Expressions

2010-04-07 Thread Patrick Maupin
On Apr 7, 3:52 am, Chris Rebert wrote: > Regular expressions != Parsers True, but lots of parsers *use* regular expressions in their tokenizers. In fact, if you have a pure Python parser, you can often get huge performance gains by rearranging your code slightly so that you can use regular expr

Re: Python and Regular Expressions

2010-04-07 Thread Richard Lamboj
Am Wednesday 07 April 2010 10:52:14 schrieb Chris Rebert: > On Wed, Apr 7, 2010 at 1:37 AM, Richard Lamboj wrote: > > i want to parse this String: > > > > version 3.5.1 { > > > >        $pid_dir = /opt/samba-3.5.1/var/locks/ > >        $bin_dir = /opt/samba-3.5.1/bin/ > > > >        service smbd

Re: Python and Regular Expressions

2010-04-07 Thread Bruno Desthuilliers
Richard Lamboj a écrit : Hello, i want to parse this String: version 3.5.1 { $pid_dir = /opt/samba-3.5.1/var/locks/ $bin_dir = /opt/samba-3.5.1/bin/ service smbd { bin = ${bin_dir}smbd -D pid = ${pid_dir}smbd.pid } servic

Re: Python and Regular Expressions

2010-04-07 Thread Chris Rebert
On Wed, Apr 7, 2010 at 1:37 AM, Richard Lamboj wrote: > i want to parse this String: > > version 3.5.1 { > >        $pid_dir = /opt/samba-3.5.1/var/locks/ >        $bin_dir = /opt/samba-3.5.1/bin/ > >        service smbd { >                bin = ${bin_dir}smbd -D >                pid = ${pid_dir}s

Python and Regular Expressions

2010-04-07 Thread Richard Lamboj
Hello, i want to parse this String: version 3.5.1 { $pid_dir = /opt/samba-3.5.1/var/locks/ $bin_dir = /opt/samba-3.5.1/bin/ service smbd { bin = ${bin_dir}smbd -D pid = ${pid_dir}smbd.pid } service nmbd { b