2.5 - Fix Whitespace in front of infix operator turns it into a prefix operator in formula tokenizer

#284 Merged at 4085940
Repository
stephenrauch
Branch
2.5
Repository
openpyxl
Branch
2.5
Author
  1. Stephen Rauch
Reviewers
Description

A space in front of - or + causes the token to be interpreted as prefix instead of infix. in the formula tokenizer.

Comments (5)

  1. CharlieC

    Thanks for this. Before I merge it, can you describe the difference between two formulae, ie. their results, with and without the whitespace? Might be useful to include this in the documentation.

  2. Stephen Rauch author

    Formula should not differ.  The whitespace in front of the + or - should not be significant. But the current code interprets the whitespace as not one of the three tokens in the list and thus decides that the + or - is prefix and not infix. IE a space makes the current code think a binary operator is an unary operator.

    1. CharlieC

      But seeing as we never evaluate formulae, this is not directly relevant but would be for anyone seeking to do so? And the recombination is correct?

      1. Stephen Rauch author

        You are likely correct that if not using this lexer with a parser, it may not matter. But, I noticed this bug because I am trying to use this lexer with a parser and it broke in this case. Thanks for picking up the change.

        1. CharlieC

          Thanks for the note. As you’re looking into this you might want to look at #723. This stuff really isn’t my area so I really appreciate contributions.