Parsing csh scripts with python

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • David Hirschfield

    #1

    Parsing csh scripts with python

    Is there a module out there that would be able to parse a csh script and
    give me back a parse tree?

    I need to be able to parse the script, modify some variable settings and
    then write the script back out so that the only changes are the
    variables I've modified (comments, ordering of statements, etc. must
    remain the same).

    I looked at shlex, but I don't think it will do what I need.
    Any suggestions would be appreciated,
    -Dave

    --
    Presenting:
    mediocre nebula.

  • Dave Benjamin

    #2
    Re: Parsing csh scripts with python

    On Tue, 28 Mar 2006, David Hirschfield wrote:
    [color=blue]
    > I need to be able to parse the script, modify some variable settings and
    > then write the script back out so that the only changes are the
    > variables I've modified (comments, ordering of statements, etc. must
    > remain the same).
    >
    > I looked at shlex, but I don't think it will do what I need.[/color]

    What about regular expressions?

    --
    .:[ dave benjamin -( ramen/sp00 )- http://spoomusic.com/ ]:.
    "one man's constant is another man's variable" - alan perlis

    Comment

    • gene tani

      #3
      Re: Parsing csh scripts with python


      Dave Benjamin wrote:[color=blue]
      > On Tue, 28 Mar 2006, David Hirschfield wrote:
      >[color=green]
      > > I need to be able to parse the script, modify some variable settings and
      > > then write the script back out so that the only changes are the
      > > variables I've modified (comments, ordering of statements, etc. must
      > > remain the same).
      > >
      > > I looked at shlex, but I don't think it will do what I need.[/color]
      >
      > What about regular expressions?
      >[/color]

      probably overkill here, but you might want to look into one of python's
      templating libs. They make generating lots of "similar except for..."
      code and markup relatively painless.

      Comment

      Working...