Discussion:
[Pyparsing] Bug report: setResultsName works inconsistently on Optional in Each
Max Rothman
2015-11-09 02:14:33 UTC
Permalink
It seems that Optional.setResultsName joined by Each does not behave
(Optional('foo')('one') & pp.Optional('bar')('two')).parseString('foo
bar')
(['foo', 'bar'], {})
(Optional('bar')('two') & Optional('foo')('one')).parseString('foo bar')
(['foo', 'bar'], {'two': [('bar', 1)]})
(Optional(Literal('bar')('two')) &
Optional(Literal('foo')('one'))).parseString('foo bar')
(['foo', 'bar'], {'two': [('bar', 1)], 'one': [('foo', 0)]})
(Optional(Literal('foo')('one')) &
Optional(Literal('bar')('two'))).parseString('foo bar')
(['foo', 'bar'], {'two': [('bar', 1)], 'one': [('foo', 0)]})
(Optional('foo')('one') + pp.Optional('bar')('two')).parseString('foo
bar')
(['foo', 'bar'], {'two': [('bar', 1)], 'one': [('foo', 0)]})

Thanks,
Max
Paul McGuire
2015-11-10 01:05:06 UTC
Permalink
Nice report, Max, especially boiling the bug repro down to a single
statement - very helpful!

Just finishing the check-in of a fix to SourceForge SVN, will be included in
the next release.

-- Paul



-----Original Message-----
From: Max Rothman [mailto:***@gmail.com]
Sent: Sunday, November 08, 2015 8:15 PM
To: pyparsing-***@lists.sourceforge.net
Subject: [Pyparsing] Bug report: setResultsName works inconsistently on
Optional in Each

It seems that Optional.setResultsName joined by Each does not behave
(Optional('foo')('one') &
pp.Optional('bar')('two')).parseString('foo
bar')
(['foo', 'bar'], {})
(Optional('bar')('two') & Optional('foo')('one')).parseString('foo bar')
(['foo', 'bar'], {'two': [('bar', 1)]})
(Optional(Literal('bar')('two')) &
Optional(Literal('foo')('one'))).parseString('foo bar') (['foo', 'bar'],
{'two': [('bar', 1)], 'one': [('foo', 0)]})
(Optional(Literal('foo')('one')) &
Optional(Literal('bar')('two'))).parseString('foo bar') (['foo', 'bar'],
{'two': [('bar', 1)], 'one': [('foo', 0)]})
(Optional('foo')('one') +
pp.Optional('bar')('two')).parseString('foo
bar')
(['foo', 'bar'], {'two': [('bar', 1)], 'one': [('foo', 0)]})

Thanks,
Max
----------------------------------------------------------------------------
--
Presto, an open source distributed SQL query engine for big data, initially
developed by Facebook, enables you to easily query your data on Hadoop in a
more interactive manner. Teradata is also now providing full enterprise
support for Presto. Download a free open source copy now.
http://pubads.g.doubleclick.net/gampad/clk?id=250295911&iu=/4140
_______________________________________________
Pyparsing-users mailing list
Pyparsing-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyparsing-users


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus


------------------------------------------------------------------------------
Loading...