Re: [Pyparsing] pyparsing svg - noob
Brought to you by:
ptmcg
From: Paul M. <pa...@al...> - 2007-11-08 15:24:43
|
I assumed that the couple always referred to an x-y coordinate pair, which is why I grouped them. If you don't wan the grouping, just make couple read: couple = floatNum + comma + floatNum and those inner groups will go away. -- Paul -----Original Message----- From: pyp...@li... [mailto:pyp...@li...] On Behalf Of Donn Ingle Sent: Thursday, November 08, 2007 9:23 AM To: pyp...@li... Subject: Re: [Pyparsing] pyparsing svg - noob > float = ... whatever ... AAARRRGGGHHH! :) A Homer moment. > phrase = OneOrMore(Group(command)) # what I would recommend instead > My recommended version of phrase makes each command its own nested > list, > like: > [['M', [float,float]], > ['C',[float,float,float,float,float,float]], > ['L',[float,float]], > ['Z']] > Your recc. phrase is producing this: M [['269.78326', '381.27104']] This is ok. C [['368.52151', '424.27023'], ['90.593578', '-18.581883'], ['90.027729', '129.28708']] This is 3 lists of 2 coords. Not a train smash, but not a single list of 6 coords. It's to do with the nature of a 'couple' I think. > for command,couples in tokens[:-1]: Now that is cool, but strange. I printed tokens[:-1] out and, oh boy, there's tupels in lists and dics too! Heck, as long as it works. \d ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ Pyparsing-users mailing list Pyp...@li... https://lists.sourceforge.net/lists/listinfo/pyparsing-users |