Skip to content

Implement Polish Notation Support

Michael Aaron Murphy requested to merge mmstick:polish into master

Implements support for polish notation in the library and binary, so calc will now support both prefix and infix modes. It works by temporarily storing operators and values into two separate vectors, and then collecting them together into infix order so that it can take advantage of the existing token parser. Parenthesis are also added to disrupt the order of operations rules that infix math has to abide by, but does not apply to prefix math. The binary now also checks for either a -p or --polish flag, then choosing the corresponding evaluator accordingly.

This will be much more useful in Ion once support for the < />/<=/>=/==/!= operators are added, which would enable for prefix-based conditional checks.

Closes #4 (closed)

Merge request reports