{"id":28958736,"url":"https://github.com/shaina-gh/operator-precedence-parsing","last_synced_at":"2025-06-23T23:06:40.931Z","repository":{"id":296211145,"uuid":"992624619","full_name":"shaina-gh/operator-precedence-parsing","owner":"shaina-gh","description":"A C implementation of Operator Precedence Parsing for validating arithmetic expressions using precedence tables in compiler design.","archived":false,"fork":false,"pushed_at":"2025-05-29T13:11:03.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-05-29T14:35:32.026Z","etag":null,"topics":["c","compiler-design","operator-precedence","operator-precedence-parser"],"latest_commit_sha":null,"homepage":"","language":"C","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/shaina-gh.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,"zenodo":null}},"created_at":"2025-05-29T13:04:31.000Z","updated_at":"2025-05-29T13:11:50.000Z","dependencies_parsed_at":"2025-05-29T14:50:10.079Z","dependency_job_id":null,"html_url":"https://github.com/shaina-gh/operator-precedence-parsing","commit_stats":null,"previous_names":["shaina-gh/operator-precedence-parsing"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/shaina-gh/operator-precedence-parsing","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shaina-gh%2Foperator-precedence-parsing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shaina-gh%2Foperator-precedence-parsing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shaina-gh%2Foperator-precedence-parsing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shaina-gh%2Foperator-precedence-parsing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shaina-gh","download_url":"https://codeload.github.com/shaina-gh/operator-precedence-parsing/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shaina-gh%2Foperator-precedence-parsing/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261571512,"owners_count":23178768,"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":["c","compiler-design","operator-precedence","operator-precedence-parser"],"created_at":"2025-06-23T23:06:37.260Z","updated_at":"2025-06-23T23:06:40.910Z","avatar_url":"https://github.com/shaina-gh.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Operator Precedence Parsing \n\n## 🎯 Aim\n\nTo implement **Operator Precedence Parsing** in C — a bottom-up parsing technique used to analyze arithmetic expressions and determine their syntactic validity using a precedence table.\n\n---\n\n## ⚙️ Logic Overview\n\nThis program:\n\n1. Accepts a set of terminal symbols.\n2. Builds an operator precedence table (with relations `\u003c`, `\u003e`, `=`, `-`).\n3. Accepts an input string (expression).\n4. Parses the string by shifting and reducing according to the precedence relations.\n5. Displays each step in the parsing process and finally accepts or rejects the string.\n\n---\n\n## 🧠 Explanation\n\n- **Terminals**: Symbols like `+`, `*`, `i`, `$`, etc., are entered by the user.\n- **Precedence Table**: A user-defined matrix indicating precedence relations between terminal pairs.\n    - `\u003c` : Shift\n    - `\u003e` : Reduce\n    - `=` : Equal precedence\n    - `-` : No relation (invalid)\n- **Parsing Strategy**:\n    - Begins with stack initialized to `$`.\n    - Input string is appended with `$`.\n    - The parser uses top of stack and current input symbol to decide:\n        - **Shift** (push input symbol onto the stack),\n        - **Reduce** (pop symbols from stack),\n        - or **Accept/Reject** based on the table and parsing completion.\n\n---\n\n## 🧪 Sample Input/Output\n\n### Input\n```yaml\nEnter the number of terminals: 4\nEnter the terminals: +i*$\nEnter the table values:\nEnter the value for + +: \u003e\nEnter the value for + i: \u003c\nEnter the value for + *: \u003c\nEnter the value for + $: \u003e\nEnter the value for i +: \u003e\nEnter the value for i i: -\nEnter the value for i *: \u003e\nEnter the value for i $: \u003e\nEnter the value for * +: \u003e\nEnter the value for * i: \u003c\nEnter the value for * *: \u003e\nEnter the value for * $: \u003e\nEnter the value for $ +: \u003c\nEnter the value for $ i: \u003c\nEnter the value for $ : \u003c\nEnter the value for $ $: -\nEnter the input string: i+ii\n```\n\n### Output\n```yaml\n**** OPERATOR PRECEDENCE TABLE ****\n+ i * $\n\n. \u003c \u003c \u003e\n  i \u003e - \u003e \u003e\n\n. \u003c \u003e \u003e\n  $ \u003c \u003c \u003c -\n\n**** STACK INPUT STRING ACTION ****\n\n$ i+ii$ Shift i\n$i +ii$ Reduce\n$ +ii$ Shift +\n$+ ii$ Shift i\n$+i *i$ Reduce\n$+ i$ Shift *\n$+ i$ Shift i\n$+i $ Reduce\n$+ $ Reduce\n$+ $ Reduce\n$ $ String is accepted\n```\n---\n\n## 🌍 Real-World Applications\n\n- **Compilers**: Parsing arithmetic and logical expressions using precedence rules.\n- **Expression Evaluators**: In calculators or interpreters, for analyzing and evaluating expressions.\n- **Syntax Checkers**: Quickly validating whether an expression conforms to defined grammatical rules.\n- **Code Optimization Tools**: Helps in understanding how expressions are structured for optimizing code execution.\n  \n---\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshaina-gh%2Foperator-precedence-parsing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshaina-gh%2Foperator-precedence-parsing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshaina-gh%2Foperator-precedence-parsing/lists"}