{"id":15174074,"url":"https://github.com/cucumber/gherkin-c","last_synced_at":"2025-10-01T10:31:50.264Z","repository":{"id":47030978,"uuid":"84756700","full_name":"cucumber/gherkin-c","owner":"cucumber","description":" [READ-ONLY] Gherkin for C - subtree of monorepo https://github.com/cucumber/cucumber -- moved to https://github.com/cucumber/gherkin","archived":true,"fork":false,"pushed_at":"2022-11-08T15:46:03.000Z","size":6335,"stargazers_count":10,"open_issues_count":2,"forks_count":12,"subscribers_count":12,"default_branch":"main","last_synced_at":"2024-04-14T13:08:33.582Z","etag":null,"topics":[],"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/cucumber.png","metadata":{"funding":{"open_collective":"cucumber"},"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-12T20:53:50.000Z","updated_at":"2023-10-31T13:46:08.000Z","dependencies_parsed_at":"2023-01-21T08:02:29.630Z","dependency_job_id":null,"html_url":"https://github.com/cucumber/gherkin-c","commit_stats":null,"previous_names":[],"tags_count":69,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cucumber%2Fgherkin-c","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cucumber%2Fgherkin-c/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cucumber%2Fgherkin-c/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cucumber%2Fgherkin-c/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cucumber","download_url":"https://codeload.github.com/cucumber/gherkin-c/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219866485,"owners_count":16554237,"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":"2024-09-27T11:23:53.333Z","updated_at":"2025-10-01T10:31:49.811Z","avatar_url":"https://github.com/cucumber.png","language":"C","funding_links":["https://opencollective.com/cucumber"],"categories":[],"sub_categories":[],"readme":"# Using the Gherkin library\n\nThe Gherkin library is using functions in the math library, so the math library needs also to be linked when the Gherkin library is used.\n\nExample:\n```c\n#include \u003clocale.h\u003e\n#include \u003cstdlib.h\u003e\n#include \u003cstring.h\u003e\n#include \u003cwchar.h\u003e\n\n#include \"ast_builder.h\"\n#include \"compiler.h\"\n#include \"error.h\"\n#include \"file_reader.h\"\n#include \"gherkin_document.h\"\n#include \"id_generator.h\"\n#include \"incrementing_id_generator.h\"\n#include \"parser.h\"\n#include \"pickle.h\"\n#include \"string_token_scanner.h\"\n#include \"token_matcher.h\"\n\nsetlocale(LC_ALL, \"en_US.UTF-8\");\nTokenMatcher* token_matcher = TokenMatcher_new(L\"en\");\nIdGenerator* id_generator = IncrementingIdGenerator_new();\nBuilder* builder = AstBuilder_new(id_generator);\nParser* parser = Parser_new(builder);\nCompiler* compiler = Compiler_new(id_generator);\nconst char* filename = \"minimal.feature\";\nFileReader* file_reader = FileReader_new(filename);\nconst wchar_t* content = FileReader_read(file_reader);\nTokenScanner* token_scanner = StringTokenScanner_new(FileReader_read(file_reader));\nint result_code = 0;\nresult_code = Parser_parse(parser, token_matcher, token_scanner);\nif (result_code == 0) {\n    const GherkinDocument* gherkin_document = AstBuilder_get_result(builder, filename);\n    result_code = Compiler_compile(compiler, gherkin_document, content);\n    if (result_code == 0) {\n        while (Compiler_has_more_pickles(compiler)) {\n            const Pickle* pickle = Compiler_next_pickle(compiler);\n            // process pickle\n            Pickle_delete(pickle);\n        }\n    }\n    GherkinDocument_delete(gherkin_document);\n}\nelse {\n    while (Parser_has_more_errors(parser)) {\n        Error* error = Parser_next_error(parser);\n        // handle error\n        Error_delete(error);\n    }\n}\nTokenScanner_delete(token_scanner);\nfree((void*)content);\nFileReader_delete(file_reader);\nCompiler_delete(compiler);\nParser_delete(parser);\nAstBuilder_delete(builder);\nid_generator-\u003eid_generator_delete(id_generator);\nTokenMatcher_delete(token_matcher);\n```\n\nThe source file [`gherkin_cli.c`](src/gherkin_cli.c) can be used as an example of using the Gherkin library.\n\nThe Gherkin library contains only an incrementing id generator (generating the ids \"1\", \"2\", ...), should UUIDs be necessary, the user needs to provide an implementation of the id_generator.h interface that generates UUID strings.\n\n# Building\n\nThree artifacts can be built:\n\n* the Gherkin library for static linking (libgherkin.a)\n* the Gherkin library for dynamic linking (libgherkin.so.\u0026lt;version\u003e)\n* the cli binary used for running the Gherkin acceptance tests (gherkin)\n\nBoth Makefiles and definition files for cmake are available in the repository.\n\n## Build using make:\n\n* The make target \"libs\" is used to build the Gherkin library for static linking\n* The make target \"libs_so\" is used to build the Gherkin library for static linking\n* The make target \"cli\" is used to biuld the cli binary (the Gherkin library for static linking will aslo be build, since it is used when linking the cli).\n\n### Building the cli with gcc:\n\n    make cli\n\n### Building the with clang\n\n    make CC=clang cli\n\n### Building Windows cli with mingw\n\nInstall the toolchain (OS X)\n\n    brew install mingw-w64\n    # Run `brew info mingw-w64` to verify the path before next command\n    export PATH=/usr/local/Cellar/mingw-w64/5.0.1/bin:$PATH\n    # Install wine - for testing\n    brew cask install xquartz\n    brew install wine\n\nBuild:\n\n    make CC=i686-w64-mingw32-gcc cli\n\n### Build the cli with other compilers\n\nEdit `src/Makefile` and set CC, CC_FLAGS, AR, AR_FLAGS, LD, LD_FLAGS appropriately, then run `make cli`\n\n## Build using cmake\n\n```\nmkdir build\ncd build\ncmake ..\ncmake --build . --target install\n```\n\nYou can use this library in your project like this\n```\ncmake_minimum_required(VERSION 3.0)\nproject(gherkincsample)\nlist(APPEND CMAKE_PREFIX_PATH \"INSTALLATION_DIRECTORY\")\nset(CMAKE_CXX_STANDARD 11)\nfind_package(gherkin REQUIRED)\nadd_executable(gherkincsample main.cpp)\ntarget_link_libraries(gherkincsample gherkin::gherkin)\n```\n\nYou can build this library as an external project in you project like this\n```\ncmake_minimum_required(VERSION 3.7)\nproject(gherkincsample)\ninclude(ExternalProject)\nExternalProject_Add(gherkin_proj\n  GIT_REPOSITORY https://github.com/cucumber/common.git\n  GIT_TAG        \u003ccommit SHA or tag\u003e\n  SOURCE_SUBDIR  gherkin/c\n)\n...\n```\n\n# Docs\n\n[The docs are here](https://cucumber.io/docs/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcucumber%2Fgherkin-c","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcucumber%2Fgherkin-c","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcucumber%2Fgherkin-c/lists"}