{"id":18944507,"url":"https://github.com/null93/expression-compiler","last_synced_at":"2026-03-26T01:30:20.634Z","repository":{"id":91417461,"uuid":"49916510","full_name":"null93/expression-compiler","owner":"null93","description":"Simple language compiler that is driven by mathematical expressions and transpiled into c++ code","archived":false,"fork":false,"pushed_at":"2018-05-28T18:53:23.000Z","size":4500,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-01T00:22:58.479Z","etag":null,"topics":["compiler","cpp","elc","expression-language","lexer","parser"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/null93.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2016-01-19T01:08:31.000Z","updated_at":"2019-04-11T15:08:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"17be7ca1-ef71-4e6d-9c59-af9ddcf8450b","html_url":"https://github.com/null93/expression-compiler","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/null93%2Fexpression-compiler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/null93%2Fexpression-compiler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/null93%2Fexpression-compiler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/null93%2Fexpression-compiler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/null93","download_url":"https://codeload.github.com/null93/expression-compiler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239945841,"owners_count":19722862,"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":["compiler","cpp","elc","expression-language","lexer","parser"],"created_at":"2024-11-08T12:47:10.952Z","updated_at":"2026-03-26T01:30:20.573Z","avatar_url":"https://github.com/null93.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Expression Compiler\n\u003e Simple language compiler that is driven by mathematical expressions and compiled into c++ code\n\n![MIT License](https://img.shields.io/badge/License-MIT-lightgrey.svg?style=for-the-badge)\n![Version 1.0.0](https://img.shields.io/badge/Version-1.0.0-lightgrey.svg?style=for-the-badge)\n![Stability Stable](https://img.shields.io/badge/Stability-Stable-lightgrey.svg?style=for-the-badge)\n![Travis CI](https://img.shields.io/travis/null93/expression-compiler.svg?style=for-the-badge\u0026colorB=9f9f9f)\n\n\u003cp align=\"center\" \u003e\n    \u003cimg src=\"docs/images/animation_1.gif\" width=\"33%\" /\u003e\n    \u003cimg src=\"docs/images/animation_2.gif\" width=\"33%\" /\u003e\n    \u003cimg src=\"docs/images/animation_3.gif\" width=\"33%\" /\u003e\n\u003c/p\u003e\n\n### About\nThe expression language compiler transpiles expression language programs into c++ source files. The expression language is a very simple language that can print values to the screen and take user input, it can save input into variables, and also apply arithmetic operations with variables and numerical literals.  The grammar for the expression language is as follows:\n\n```\n\u003cvariable\u003e          =\u003e  /^[a-zA-Z]+[a-zA-Z0-9_]*$/\n\u003cstring_literal\u003e    =\u003e  /^\"(?:[^\"]|\\\\\")*\"$/\n\u003cnumeric_literal\u003e   =\u003e  /^(?:[0-9]+(?:\\.[0-9]+)?|(?:\\.[0-9]+))$/\n\u003cprogram\u003e           =\u003e  \u003cstatement\u003e \u003cmore_stmts\u003e\n\u003cmore_stmts\u003e        =\u003e  \u003cstatement\u003e \u003cmore_stmts\u003e | ;\n\u003cstatement\u003e         =\u003e  \u003cinput\u003e \";\" | \u003coutput\u003e \";\" | \u003cassignment\u003e \";\"\n\u003cinput\u003e             =\u003e  \u003cinput_op\u003e \u003cmore_input\u003e\n\u003cmore_input\u003e        =\u003e  \u003cinput\u003e | ;\n\u003cinput_op\u003e          =\u003e  \"\u003e\u003e\" \u003cvariable\u003e\n\u003coutput\u003e            =\u003e  \u003coutput_op\u003e \u003cmore_output\u003e\n\u003cmore_output\u003e       =\u003e  \u003coutput\u003e | ;\n\u003coutput_op\u003e         =\u003e  \"\u003c\u003c\" \u003coutput_val\u003e\n\u003coutput_val\u003e        =\u003e  \u003cvariable\u003e | \u003cstring_literal\u003e | \u003cnumeric_literal\u003e\n\u003cassignment\u003e        =\u003e  \u003cvariable\u003e \"=\" \u003ccombination\u003e\n\u003ccombination\u003e       =\u003e  \u003cfactor\u003e \u003ccombination_prime\u003e\n\u003ccombination_prime\u003e =\u003e  \"+\" \u003cfactor\u003e \u003ccombination_prime\u003e | \"-\" \u003cfactor\u003e \u003ccombination_prime\u003e | ;\n\u003cfactor\u003e            =\u003e  \u003cpower\u003e \u003cfactor_prime\u003e\n\u003cfactor_prime\u003e      =\u003e  \"*\" \u003cpower\u003e \u003cfactor_prime\u003e | \"/\" \u003cpower\u003e \u003cfactor_prime\u003e | ;\n\u003cpower\u003e             =\u003e  \u003cfork\u003e \"^\" \u003cpower\u003e | \u003cfork\u003e\n\u003cfork\u003e              =\u003e  \"(\" \u003ccombination\u003e \")\" | \u003cvariable\u003e | \u003cnumeric_literal\u003e\n```\n\n### Examples\nAn example program written in expression language can be found below. The program simply asks the user for a radius and computes the area and circumference of a circle with the given radius. An expression language program has the extension __el__.\n\n```\n\u003c\u003c \"Enter radius \u003e\u003e \";\n\u003e\u003e r;\n\npi = 3.14159;\n\nA = pi*r^2.0;\nC = 2*pi*r;\n\n\u003c\u003c \"Area: \"          \u003c\u003c A \u003c\u003c \"\\n\";\n\u003c\u003c \"Circumference: \" \u003c\u003c C \u003c\u003c \"\\n\";\n```\n\nAssuming that the above expression language program is saved to a file named _main.el_. You can transpile the program above to c++ code by running the following command:\n\n```bash\n./bin/elc main.el\n```\n\n### Build System\nThis project uses a simple makefile for it's _build system_. Run `make elc` to compile the expression language compiler–the bindary can be found in the _bin_ folder. Run `make tests` to compile the test suite–the binary can be found in the _bin_ folder.\n\n### Program Execution\nOnce the expression language source code is transpiled into c++, you can compile the outputted c++ code using _g++_ as follows:\n\n```bash\ng++ source.cpp -o main\n```\n\nThe program can then be ran as follows:\n\n```bash\n./main\n```\n\nIn order to run tests run the following:\n\n```bash\n./bin/tests\n```\n\nIf nothing shows up, then all tests passed successfully. Otherwise, it will display which tests failed.\n\n### Limitations\nThe expression language compiler is very simple and the compiler itself has no options. One thing to implement in the future is to specify the path for the outputted transpiled c++ file. Another thing to implement is to compile with g++ right after generating the transpiled c++ source code.\n\n### Acknowledgments\nThis project was part of the curriculum for CS473–Compilers at the University of Illinois at Chicago. Test cases were written by Professor Hummel.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnull93%2Fexpression-compiler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnull93%2Fexpression-compiler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnull93%2Fexpression-compiler/lists"}