The current code to manage the clipboard only supports a subset of functions managed by the calculator, has some issues to parse them (many false positives or issues with locales due to the conversion to en-us format but ignoring that '.' and ',' can be used for other purposes in the original locale) and very complicated to maintain/add new features (sin, pin, square, etc..).
In order to simplify and make this function more robust, we should instead use a language parser, more suited to our needs.
My proposal would be to use a custom Lexer to support all the different number formats (hex, bin, dec, bin, dec with exponent, ...) and modes (standard, programmer, etc...) we support and use a LR parser to verify and generate the list of commands. This solution would have many advantages:
- very easy to add new operator whatever their types (binary, pre-unitary or post-unitary)
- the parser will generate the sequence of commands while verifying the text, easier to maintain
- no false positive possible
In my proto-PR, I used Bison, a GPL v3 tool but providing an explicit exception to allow the use of the generated code without license.
It already manages a variety of features not currently available:
sinus/cos/tan

** Power, square, cube ** (#299)

more sign operators

Binary operations: OR, NOT, AND, XOR


and fix some reported bugs:
Proto-PR available here
https://github.com/rudyhuyn/calculator/tree/AddExpressionParser
remaining:
- add unit tests
- it only supports 0;0 and 0;3 grouping for the moment
The current code to manage the clipboard only supports a subset of functions managed by the calculator, has some issues to parse them (many false positives or issues with locales due to the conversion to en-us format but ignoring that '.' and ',' can be used for other purposes in the original locale) and very complicated to maintain/add new features (sin, pin, square, etc..).
In order to simplify and make this function more robust, we should instead use a language parser, more suited to our needs.
My proposal would be to use a custom Lexer to support all the different number formats (hex, bin, dec, bin, dec with exponent, ...) and modes (standard, programmer, etc...) we support and use a LR parser to verify and generate the list of commands. This solution would have many advantages:
In my proto-PR, I used Bison, a GPL v3 tool but providing an explicit exception to allow the use of the generated code without license.
It already manages a variety of features not currently available:
sinus/cos/tan

** Power, square, cube ** (#299)

more sign operators

Binary operations: OR, NOT, AND, XOR


and fix some reported bugs:
Proto-PR available here
https://github.com/rudyhuyn/calculator/tree/AddExpressionParser
remaining: