{"id":26428962,"url":"https://github.com/brokenprogrammer/expression-parser","last_synced_at":"2025-03-18T04:52:42.939Z","repository":{"id":81706133,"uuid":"50916885","full_name":"brokenprogrammer/Expression-Parser","owner":"brokenprogrammer","description":"An Expression parser written in C capable of parsing advanced math expressions.","archived":false,"fork":false,"pushed_at":"2016-02-21T15:14:18.000Z","size":512,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-21T18:58:59.421Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/brokenprogrammer.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}},"created_at":"2016-02-02T11:48:15.000Z","updated_at":"2016-02-02T11:53:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"fc22fd94-2285-4bc4-b8b2-7d26d85dfe13","html_url":"https://github.com/brokenprogrammer/Expression-Parser","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/brokenprogrammer%2FExpression-Parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brokenprogrammer%2FExpression-Parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brokenprogrammer%2FExpression-Parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brokenprogrammer%2FExpression-Parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brokenprogrammer","download_url":"https://codeload.github.com/brokenprogrammer/Expression-Parser/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244159992,"owners_count":20408019,"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":"2025-03-18T04:52:42.420Z","updated_at":"2025-03-18T04:52:42.928Z","avatar_url":"https://github.com/brokenprogrammer.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Expression-Parser\nAn Expression parser written in C capable of parsing advanced math expressions.\nThe Expression Parser supports parsing normal math expressions, parsing math expressions\nfrom the command line arguments and parsing math expressions in the form of Polish Notations.\n\n#Parsing Math Expressions\nTo parse normal math expressions like 15 + 25 you can simply do it by initializing \ntwo Stacks and then call the parseExpression function together with the string to parse.\n```c\n  Stack *operationStack = initWithOperand(0);\n  Stack *operandStack = initWithOperand(0);\n    \n  parseExpression(\"15 +15-20 + 20\", 10, \u0026operationStack, \u0026operandStack);\n  \n  printf(\"\\n%f\\n\", calculate(\u0026operationStack, \u0026operandStack));\n```\n\n#Parse From Command Line\nTo parse an expression from the command line you can have this code in main.c\n```c\n  Stack *operationStack = initWithOperand(0);\n  Stack *operandStack = initWithOperand(0);\n  \n  //If on XCode: \n  //Change command line args from Product -\u003e Scheme -\u003e Edit Scheme then Arguments\n  parseCommandlineArgs(argc, argv, \u0026operationStack, \u0026operandStack);\n  \n  printf(\"\\n%f\\n\", calculate(\u0026operationStack, \u0026operandStack));\n```\n\n#Parsing Polish Notations\nThe feature of parsing polish notations exists as well, if you are not familiar with\npolish notations you can read more about them here: [Polish Notations](https://en.wikipedia.org/wiki/Polish_notation)\nIn the applications current state the Stack has to be reversed before it can be correctly calculated,\nreason behind it is the Stack data structure which is being used during the parsing phase.\n```c\n  Stack *operationStack = initWithOperand(0);\n  \n  parsePolishNotation(\"+ 3 4\", 10, \u0026operationStack);\n  \n  reverseStack(\u0026operationStack);\n  \n  printf(\"\\n%f\\n\", calculatePolishNotation(\u0026operationStack));\n```\n\n#Todo:\nRight now there is no added unary operations to the parser. The functionality to calculate using Unary\nOperations and Constants is there, there is just no known Constants and unary operations added to the\napplication.\nI have sometimes experienced bugs with the reverseStack function for the Stack data structure. Where \nafter using it the display function results in an endless loop.\nRecently when i have tried compiling there has been no bugs so i have not found anything more about it.\nIf you find any bugs please report them as issues for this repo.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrokenprogrammer%2Fexpression-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrokenprogrammer%2Fexpression-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrokenprogrammer%2Fexpression-parser/lists"}