[BangPypers] Do you think a more declarative RE syntax would make the world a better place ?
Vishal
vsapre80 at gmail.com
Tue Aug 10 07:28:48 CEST 2010
Thanks everybody for the insight that you have shared with me and the group.
As of now, I am abandoning this weekend project, and have started looking
for something else :))
BTW, in the process of designing the semantics of the YAML description, I
had to read through the Python RE module docs a few times and that has
clarified my understanding of the regular expressions in general. So now I
can atleast look at a regex and successfully try to figure out what its
trying to say.
Thanks and best regards,
Vishal
On Tue, Aug 10, 2010 at 8:57 AM, Dhananjay Nene <dhananjay.nene at gmail.com>wrote:
> On Mon, Aug 9, 2010 at 5:04 PM, Vishal <vsapre80 at gmail.com> wrote:
>
> > Hello fellas,
> >
> > I am trying to create a python function that can take an plain english
> > description of a regular expression and return the regular expression to
> > the
> > caller.
> >
> > Currently I am thinking of the description in YAML format. So, we can
> store
> > the description as a raw string variable, which is passed on to this
> > another
> > function and output of that function is then passed to the 're' module.
> > Following is a rather simplistic example:
> >
> > # a(b|c)d+e*
> >
> > re1 = """
> >
> > - literal: 'a'
> > - one_of: 'b,c'
> > - one_or_more_of: 'd'
> > - zero_or_more_of: 'e'
> > """
> >
> > myre = re.compile(getRegex(re1))
> >
> > myre.search(...)
> >
> > etc.
> >
> > Does anyone think something of this sort would be of wider use? Do you
> know
> > already existing packages that can do it? What are the limitations that
> you
> > see to this approach? Does anyone think, having the declarative string in
> > code, would make it more maintainable?
> >
>
> The real struggle here is the complexity of modeling the problem you are
> attempting to solve. RE syntax per se isn't the problem though it could be
> recast a bit in favour of readability and grokkability away from brevity
> (not that I am in favour of that). The issue is really the complexity of
> the
> diversity of situations that RE expressions attempt to model. Should you
> wan't to attempt to support the entire range of scenarios that REs can
> manage, I imagine the yaml will become excessively verbose to manage and
> will eventually start suffering similar difficulties of grokkability that
> complex REs end up with. While I don't think there's a good solution for
> that, I think a victory if at all feasible could be better had through a
> better modeling of how pattern matching expressions can be composed
> (differently from current RE structures) rather than making the current
> expression structures verbose and declarative.
>
> Dhananjay
>
> _______________________________________________
> > BangPypers mailing list
> > BangPypers at python.org
> > http://mail.python.org/mailman/listinfo/bangpypers
> >
>
>
>
> --
> --------------------------------------------------------
> blog: http://blog.dhananjaynene.com
> twitter: http://twitter.com/dnene
> _______________________________________________
> BangPypers mailing list
> BangPypers at python.org
> http://mail.python.org/mailman/listinfo/bangpypers
>
--
Thanks and best regards,
Vishal Sapre
---
"So say...Day by day, in every way, I am getting better, better and better
!!!"
"A Strong and Positive attitude creates more miracles than anything else.
Because...Life is 10% how you make it, and 90% how you take it"
"Diamond is another piece of coal that did well under pressure”
"May we do good and not evil. May we find forgiveness for ourself and
forgive others. May we share freely, never taking more than we give."
More information about the BangPypers
mailing list