Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ryansilva2004/simple-lex-yacc-calculator

This is a simple calculator implemented using Lex and Yacc. It supports basic arithmetic operations, square root, exponentiation, and modulo operation. It also handles syntax errors and division by zero errors.
https://github.com/ryansilva2004/simple-lex-yacc-calculator

calculator lexical-analyzer yacc-lex

Last synced: 3 days ago
JSON representation

This is a simple calculator implemented using Lex and Yacc. It supports basic arithmetic operations, square root, exponentiation, and modulo operation. It also handles syntax errors and division by zero errors.

Awesome Lists containing this project

README

        

# Simple Lex/Yacc Calculator

This is a simple calculator implemented using Lex and Yacc. It supports basic arithmetic operations, square root, exponentiation, and modulo operation.

## Features

- **Basic Arithmetic Operations**: The calculator can perform addition, subtraction, multiplication, and division.
- **Square Root**: The calculator can compute the square root of a number using the `sqrt()` function.
- **Exponentiation**: The calculator can perform exponentiation using the `^` operator.
- **Modulo Operation**: The calculator can perform modulo operation using the `%` operator.
- **Error Handling**: The calculator can handle syntax errors and division by zero errors.
- **Commands**: The calculator supports commands for displaying help instructions (`h`) and quitting the application (`q`).

## Usage

To use the calculator, simply enter an expression or a command. Here are some example expressions for each feature:

- **Basic Arithmetic Operations**:
- Addition: `2 + 3`
- Subtraction: `5 - 2`
- Multiplication: `4 * 5`
- Division: `20 / 4`
- **Square Root**: `sqrt(9)`
- **Exponentiation**: `2^3`
- **Modulo Operation**: `10 % 3`
- **Commands**:
- Display help instructions: `h`
- Quit the application: `q`

Please note that spaces are not allowed in the expressions.

## Authors

This calculator was created by Ryan, Vihanga, Geemith, and Pramuditha © 2023.

## Disclaimer

This calculator is provided as-is, and the authors are not responsible for any errors or inaccuracies in the calculations. Always double-check your results with a trusted source.

## License

This project is licensed under the MIT License. See the LICENSE file for details.

## Contributing

Contributions are welcome! Please read the CONTRIBUTING.md file for details on how to contribute to this project.

## Contact

If you have any questions or feedback, please feel free to contact the authors.

## Acknowledgments

We would like to thank our professor and classmates for their valuable feedback and suggestions during the development of this calculator.