Re: [Pyparsing] pyparsing svg - noob
Brought to you by:
ptmcg
From: Ralph C. <ra...@in...> - 2007-11-08 10:29:21
|
Hi Donn, > from pyparsing import Word, Literal, alphas, nums, Optional, OneOrMore > > command = Word("MLCZ") > comma = Literal(",") > dot = Literal(".") > float = nums + dot + nums > couple = float + comma + float > > phrase = OneOrMore(command + OneOrMore(couple | ( couple + couple ) ) ) nums is just str('0123456789') so you're saying that you literally want '0123456789.0123456789' for every float. Change it to float = Word(nums) + dot + Word(nums) and all will be fine. You may find it's better to check you've the right number of couples depending on which command it is though, e.g. the grammar says move = Literal('M') + couple command = ... | move | ... Cheers, Ralph. |