Skip to content
This repository has been archived by the owner on Jul 27, 2021. It is now read-only.

Latest commit

 

History

History
24 lines (17 loc) · 1 KB

README.md

File metadata and controls

24 lines (17 loc) · 1 KB

Calculator application

Test

How to use

Run htncalc.exe and input expressions for calculation. For exit input "q" or "quit" command.

Supported features

  • Integer and decimal positive numbers
  • Arithmetic operations +, -, *, /
  • Brackets
  • abs() function

How it works

  1. ExpressionParser performs lexical analysis of an input string expression.
  2. PermutationsBuilder builds a terms tree considering sub-expressions priority with different "permutations services" which implements ITermPermuter interface. The order is important:
    1. BracketTermPermuter - distinguishes brackets
    2. FunctionTermPermuter - works with functions like abs(...)
    3. MulDivTermPermuter - for multiplication and division operations
    4. AddSubTermPermuter - for addition and subtraction operations
  3. ExpressionTreeBuilder builds an expression tree, consists of IExpressionNode elements which can calculate their own value.