{"id":18497582,"url":"https://github.com/csb6/ginevra","last_synced_at":"2025-05-14T05:14:07.569Z","repository":{"id":115656213,"uuid":"223537456","full_name":"csb6/ginevra","owner":"csb6","description":"A very basic C++ preprocessor supporting only #define directives, based on the ginevra program in Arthur Pyster's book, Compiler Design and Construction","archived":false,"fork":false,"pushed_at":"2019-12-17T23:11:30.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-17T00:21:09.536Z","etag":null,"topics":["cpp17","preprocessor"],"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/csb6.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-11-23T05:40:15.000Z","updated_at":"2020-05-13T22:30:24.000Z","dependencies_parsed_at":null,"dependency_job_id":"7dcc17f6-fee4-4305-b29a-85f7a745cabb","html_url":"https://github.com/csb6/ginevra","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/csb6%2Fginevra","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csb6%2Fginevra/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csb6%2Fginevra/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csb6%2Fginevra/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/csb6","download_url":"https://codeload.github.com/csb6/ginevra/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254076851,"owners_count":22010611,"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":["cpp17","preprocessor"],"created_at":"2024-11-06T13:35:00.960Z","updated_at":"2025-05-14T05:14:07.503Z","avatar_url":"https://github.com/csb6.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ginevra++\n\nThis is a collection of two implementations of a very basic C-like preprocessor that operates on any text file with a `.cpp` or `.h` extension. It only implements the `#define` preprocessor directive, but it tokenizes the content of the file, replaces all tokens that match symbols\ndefined in the `#define` directives, and prints out the result to the console.\n\nBasic error handling is included: it checks that the given file exists and has the right file extension, and the program will print errors if a token ends unexpectedly.\n\nBoth programs are based on the ginevra preprocessor implemented in Arthur Pyster's book\n*Compiler Design and Construction*, but both take advantage of C++'s standard library to\nsimplify the implementation immensely. Also, since the book's implementation of the symbol\ntable used a linked list instead of a hash map, this implementation may in fact be\nfaster than the C version found in the book for programs with large numbers of `#define`s!\n\nThis project was more challenging than I expected, but it helped me gain experience\nin C++'s fstreams, as well as when object-oriented programming does/doesn't work well\n\n### ginevra++.cpp\n\nThis is the more object-oriented version of the program, although it is quite a bit longer\nthan `better.cpp` and much more complicated. However, there is slightly more error checking,\nand if this were to be expanded into a full compiler, it would probably be more maintainable\nand extensible.\n\n### better.cpp\n\nAfter writing `ginevra++.cpp` and feeling dissatisfied with its complexity, I rewrote\nthe program in a more procedural form, removing the separate constants representing tokens\nand greatly simplifying the conditional logic of the parser while still preserving nearly\nall of the features. The code is not the prettiest, but I think that it is much more easy to\nreason about than the more OOP version in `ginevra++.cpp`.\n\n## Usage\n\nBuilding `ginevra++.cpp` is built with C++17, although it should also be able to compile.\nunder C++14. Run `./build-ginevra++.sh`, then run `./ginevra++ [some .cpp or .h file]`\n\nBuilding `better.cpp` requires at least C++17. Run `./build.sh`, then run\n`./better [some .cpp or .h file]`","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcsb6%2Fginevra","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcsb6%2Fginevra","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcsb6%2Fginevra/lists"}