{"id":20269909,"url":"https://github.com/teliosdev/preproc","last_synced_at":"2025-10-03T23:21:14.915Z","repository":{"id":187983694,"uuid":"677693735","full_name":"teliosdev/preproc","owner":"teliosdev","description":null,"archived":false,"fork":false,"pushed_at":"2023-10-22T07:00:01.000Z","size":38,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-10T23:38:41.858Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","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/teliosdev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2023-08-12T10:16:25.000Z","updated_at":"2023-08-12T10:29:37.000Z","dependencies_parsed_at":null,"dependency_job_id":"22d44f41-3d8a-4eba-a784-36d27fab77df","html_url":"https://github.com/teliosdev/preproc","commit_stats":null,"previous_names":["teliosdev/preproc"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/teliosdev/preproc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teliosdev%2Fpreproc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teliosdev%2Fpreproc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teliosdev%2Fpreproc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teliosdev%2Fpreproc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/teliosdev","download_url":"https://codeload.github.com/teliosdev/preproc/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teliosdev%2Fpreproc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278240800,"owners_count":25954278,"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","status":"online","status_checked_at":"2025-10-03T02:00:06.070Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-11-14T12:28:02.124Z","updated_at":"2025-10-03T23:21:14.873Z","avatar_url":"https://github.com/teliosdev.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PreProc\n\n**PreProc** is a command line tool to run preprocessor directives in a file.\nIt's pretty simple, and is meant to be an analogue to the C preprocessor; but\nless fixated on C.\n\n## Usage\n\n```\npreproc [options] \u003cinput file\u003e -o \u003coutput file\u003e\n```\n\nThe `\u003cinput file\u003e` is the file to run the preprocessor on. The `-o` option\nspecifies the output file. If the output file is not specified, the output will\nbe written to stdout.\n\nThe input file should be a UTF-8 text file.  Each line is processed separately;\nif the line starts with a preprocessor directive prefix, the line is parsed\nas a preprocessor directive.  Otherwise, the line is written to the output\nfile.  The preprocessor directive prefix is `#` by default, though is\ndetermined by the file extension, but can be changed with the `-c`/`--comment`\noption.\n\nThere are two main tables of values: the definition table, and the replacement\ntable.  The definition table is a table of variables and their values, when\nused in expressions.  The replacement table is a table of variables and their\nvalues, and the corresponding patterns in the non-directive text are replaced\nwith the value of the variable.  By default, definitions are not replacements;\nhowever, you can declare a replacement with `#replace`.\n\nThe current available preprocessor directives are:\n\n- `#if \u003cexpr\u003e`: If the expression evaluates to true, the following lines\n  are passed through.  Otherwise, they are ignored.\n- `#elsif \u003cexpr\u003e`: If all of the previous `#if` or `#elsif` evaluated to\n  false, and this expression evaluates to true, the following lines are\n  passed through.  Otherwise, they are ignored.\n- `#else`: If all of the previous `#if` or `#elsif` evaluated to false,\n  the following lines are passed through.  Otherwise, they are ignored.\n- `#endif`: Ends the previous `#if`, `#elsif`, or `#else` block.\n- `#replace \u003cname\u003e`: Replaces all instances of `name` with the value of\n  the variable `name`.  If the variable is not defined, it is replaced\n  with the empty string.\n- `#replace \u003cname\u003e \u003cexpr\u003e`: Replaces all instances of `name` in the text\n  with the value of the expression `expr`.  If the expression cannot be\n  evaluated, it is replaced with the empty string.\n- `#unrep \u003cname\u003e`: Stops substitution of `name` in the current scope.\n- `#define \u003cname\u003e \u003cexpr\u003e`: Defines the variable `name` to be the value\n  of the expression `expr`.  If the expression cannot be evaluated, the\n  variable is set to null.\n- `#error \u003cexpr\u003e`: Marks the current line as an error.  If the expression\n  cannot be evaluated, the error is marked as `null`.  This will cause\n  the preprocessor to exit with an error code, after processing the whole\n  file.\n\n## Examples\n\nTo demonstrate the definitions and replacements as expressed above, an example\ninput file is:\n\n```\n#define WORLD \"world\"\nhello, WORLD!\n#replace WORLD\nhello, WORLD!\n#replace WORLD null\nhello, WORLD!\n```\n\nThe output of processing this file is:\n\n```\nhello, WORLD!\nhello, world!\nhello, !\n```\n\n# Why?\n\nBecause.\n\nI wanted to write it.\n\n# Is it any good?\n\nYes.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteliosdev%2Fpreproc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fteliosdev%2Fpreproc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteliosdev%2Fpreproc/lists"}