Skip to content

0xHaru/Precedence-climbing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Precedence climbing

This program aims to provide a simple example of parsing expressions by precedence climbing.

Compilation and usage

make
./calc

Example

> 2 + 3 * 4
(2 + (3 * 4)) = 14.00

> (2 - 3) * 4
((2 - 3) * 4) = -4.00

> -2 ^ 2
-(2 ^ 2) = -4.00

> 2 ^ 2 ^ 3
(2 ^ (2 ^ 3)) = 256.00

> (10 * (350 + -25)) / 2
((10 * (350 + -25)) / 2) = 1625.00

> 100 + -2 ^ -(2 + 1) * 25
(100 + (-(2 ^ -(2 + 1)) * 25)) = 96.88

References

License

This source code is licensed under the GNU General Public License v3.0.