{"id":16905983,"url":"https://github.com/hopding/arithmetic-evaluator","last_synced_at":"2025-03-20T16:23:55.460Z","repository":{"id":87966539,"uuid":"172254305","full_name":"Hopding/arithmetic-evaluator","owner":"Hopding","description":"Parse and evaluate arithmetic expressions","archived":false,"fork":false,"pushed_at":"2019-05-05T17:59:51.000Z","size":87,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-25T15:23:56.581Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Hopding.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-02-23T19:22:46.000Z","updated_at":"2019-05-05T18:00:23.000Z","dependencies_parsed_at":"2023-05-22T04:15:39.865Z","dependency_job_id":null,"html_url":"https://github.com/Hopding/arithmetic-evaluator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hopding%2Farithmetic-evaluator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hopding%2Farithmetic-evaluator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hopding%2Farithmetic-evaluator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hopding%2Farithmetic-evaluator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Hopding","download_url":"https://codeload.github.com/Hopding/arithmetic-evaluator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244647873,"owners_count":20487160,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-13T18:40:27.987Z","updated_at":"2025-03-20T16:23:55.439Z","avatar_url":"https://github.com/Hopding.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Arithmetic Evaluator\n\nThis program implements an arithmetic expression evaluator in Python. When evaluating an expression, the following steps are performed:\n\n1. **Input** - When the program starts, it prompts the user to enter an arithmetic expression as a string. After the program finishes processing one expression, it stops.\n2. **Skip Data Validation** - The validation step would be rather complicated. We want to focus the program on the main technical problem. So we'll require the input string to have the following properties:\n\n   - The operands must be non-negative integers.\n   - The operators can only be: +, -, \\*, /.\n   - The delimiters can only be ( and ).\n   - The whole input string is a valid arithmetic expression.\n\n3. **Tokenization** - We iterate through the input string character by character, and convert it into a sequence of four token types (`Operand`, `Operator`, `OpeningParen`, `ClosingParen`). Whitespace separators are stripped out. Multi-digit integers are supported.\n\n4. **Postfix Notation Converion** - We convert the sequence of tokens from prefix notation to postfix notation. This makes the evaluation step much easier.\n\n5. **Evaluate Postfix Expression** - We evaluate the postfix expression.\n\n6. **Output** - We output the answer on the screen.\n\n## Requirements\n\nTo run this program, you must have python 3.6 installed on your machine. Older and newer versions may work, but only 3.6 has been tested.\n\n## Running\n\n- You can use the included `run` script:\n  ```\n  chmod +x run\n  ./run\n  ```\n- Alternatively, you can run the `main.py` script directly:\n  ```\n  python3.6 src/main.py\n  ```\n\n## Division By Zero\n\nIf you try to evaluate an expression that includes division by zero, the program will exit with a `ZeroDivisionError`. For example:\n\n```\n$ ./run\nEnter an arithmetic expression: 1 / 0\nTraceback (most recent call last):\n  File \"src/main.py\", line 11, in \u003cmodule\u003e\n    result = eval_postfix(postfix_tokens).value\n  File \"/CS5130/project1/src/postfix_evaluation.py\", line 27, in eval_postfix\n    res_int = do_eval(first, second, operator)\n  File \"/CS5130/project1/src/postfix_evaluation.py\", line 13, in do_eval\n    return first // second\nZeroDivisionError: integer division or modulo by zero\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhopding%2Farithmetic-evaluator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhopding%2Farithmetic-evaluator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhopding%2Farithmetic-evaluator/lists"}