[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [augeas-devel] shellvars - regex parsing help



On Mon, 2010-01-18 at 16:39 -0500, Adam Stokes wrote:
> ----- "David Lutterkort" <lutter redhat com> wrote:
> 
> > On Thu, 2010-01-14 at 12:03 -0500, Adam Stokes wrote:
> 
> > 
> > The expression after the '-' is not right: you have
> >         /([ \t]key_re . [ \t]*=[ \t]*.*[ \t\n])/
> > 
> > That's one literal regexp; you're missing a bunch of '/' to end/start
> > regular expression literals.
> > 
> > I think what you mean is
> >         /[ \t]*/ . key_re . /[ \t]*=[ \t]*.*/
> >         
> > David
> 
> Once setting this as above augparse takes about 5 minutes longer to
> run through the test module:

Ugh .. yeah. The culprit is that key_re is defined as 

  let key_re = /[A-Za-z0-9_]+(\[[0-9]+\])?/ - "unset" - "export"

subtracting that out of line_re produces a heinously big regexp. If you
ignore unset and export, and only subtract out the first part of key_re:

let comment =
      let simple_key = /[A-Za-z0-9_]+(\[[0-9]+\])?/ in
      let line_re = /([^ \t\n].*[^ \t\n]|[^ \t\n])/ - /[ \t]*/ . simple_key . /[ \t]*=[ \t]*.*/ in
      [ label "#comment" . del /#[ \t]*/ "# " . store line_re . del /\n/ "\n" ]

the test fails much faster ;)

> [root jak dist]# augparse t.aug 
> t.aug:5.4-6.28:exception thrown in test
> t.aug:5.9-.47:exception: Iterated lens matched less than it should
>     Lens: /usr/share/augeas/lenses/dist/shellvars.aug:48.12-.53:
>     Error encountered at 1:0 (0 characters into string)
>                                <|=|# TESTINGVAR=VAL\n>         

That (and the next error) just shows that you've successfully removed
such a line from being a comment; you still need to add logic to kv to
parse such a line and create a 'commented' subnode, similar to how you
did that for the NFS lens.

David




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]