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.
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.
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.
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.
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.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?
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.
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.