shlex parsing

Dan Stromberg drsalists at gmail.com
Wed Jul 27 22:44:55 CEST 2011


I've not used the shlex module, but this feels more like an issue to address
with a parser than for a lexical analyzer - or perhaps even both, since
you're splitting on whitespace sometimes, and matching square brackets
sometimes.

I've used pyparsing for stuff a bit similar to this.

Or here's a list:
http://wiki.python.org/moin/LanguageParsing

On Wed, Jul 27, 2011 at 12:30 PM, Karim <karim.liateni at free.fr> wrote:

>
> Hello All,
>
> I would like to parse this TCL command line with shlex:
>
> '-option1 [get_rule A1 B2] -option2 $VAR -option3 TAG'
>
> And I want to get the splitted list:
>
> ['-option1', '[get_rule A1 B2]', '-option2',  '$VAR', '-option3',  'TAG']
>
> Then I will gather in tuple 2 by 2 the arguments.
>
> I tried to the shlec properties attributes 'quotes', 'whitespace', etc...
>
> But I make 'choux blanc'.
>
> If somebody has complex experiences with  this module I am in.
>
> Cheers
> Karim
> --
> http://mail.python.org/**mailman/listinfo/python-list<http://mail.python.org/mailman/listinfo/python-list>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110727/98d4633e/attachment.html>


More information about the Python-list mailing list