{"id":13831572,"url":"https://github.com/jonathan-beard/simple_wc_example","last_synced_at":"2025-05-05T16:20:29.715Z","repository":{"id":5913979,"uuid":"7133241","full_name":"jonathan-beard/simple_wc_example","owner":"jonathan-beard","description":"simple word count example using flex/bison parser","archived":false,"fork":false,"pushed_at":"2023-11-23T03:11:17.000Z","size":249,"stargazers_count":140,"open_issues_count":1,"forks_count":43,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-30T22:12:58.094Z","etag":null,"topics":["bison","c-plus-plus","count","flex","parse","tutorial"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jonathan-beard.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}},"created_at":"2012-12-12T16:13:52.000Z","updated_at":"2025-03-09T08:11:06.000Z","dependencies_parsed_at":"2024-01-15T15:11:25.145Z","dependency_job_id":"5835016b-b7ce-47d8-9322-6e03f7a15e62","html_url":"https://github.com/jonathan-beard/simple_wc_example","commit_stats":{"total_commits":63,"total_committers":10,"mean_commits":6.3,"dds":"0.23809523809523814","last_synced_commit":"52abeaa1acc7fffaab9e52453efc81a3f721be42"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathan-beard%2Fsimple_wc_example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathan-beard%2Fsimple_wc_example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathan-beard%2Fsimple_wc_example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathan-beard%2Fsimple_wc_example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonathan-beard","download_url":"https://codeload.github.com/jonathan-beard/simple_wc_example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252531879,"owners_count":21763293,"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":["bison","c-plus-plus","count","flex","parse","tutorial"],"created_at":"2024-08-04T10:01:31.593Z","updated_at":"2025-05-05T16:20:29.699Z","avatar_url":"https://github.com/jonathan-beard.png","language":"C++","readme":"### Simple Word Count Parser Example\n=================\n\n### Build Status\nTested on linux and OS X\n\n[![Build Status](https://travis-ci.org/jonathan-beard/simple_wc_example.svg?branch=master)](https://travis-ci.org/jonathan-beard/simple_wc_example)\n\n### About\n\nSo this is a super simple parser example. The tutorial is located here:\n\u003ca href=\"http://www.jonathanbeard.io/tutorials/FlexBisonC++.html\" target=\"_blank\"\u003elink\u003c/a\u003e\n\nBetween the tutorial and the code you should be able to get started with more\nadvanced projects using C++ and Flex/Bison. Admittedly the example itself is a\nbit contrived, however it's mean to be simple and get the point across. If\nthere are changes in Flex/Bison that prevent the example from compiling or if\nyou just have improvements, feel free to generate a pull request or just shoot\nme an e-mail.\n\nTo compile just download and run make, there's a super simple test harness to\nmake sure it runs in the \u003ctt\u003etest\u003c/tt\u003e dir.\n\nOr you use CMake.\n\n    mkdir build/\n    cmake ..\n    make\n\nor with clang\n\n    mkdir build/\n    CC=clang CXX=clang++ cmake ..\n    make\n\nor with clang with optimisations\n\n    mkdir build/\n    CC=clang CXX=clang++ cmake .. -DCMAKE_BUILD_TYPE=Release\n    make\n\nTo run the simple test after make call\n\n    ctest\n\n## NOTES\n* **OS X Users** I've heard of some issues compiling if you've installed \ncommand line tools, then XCode.app afterwards on Catalina (with bash). When compiling with \n```clang++```, the C++ header files aren't found. If you have this issue, exporting an environment\nvariable, such as this, \n```export CXX=/usr/bin/clang++```, seems to be a workaround. If anybody has a better\nsolution (aside from wiping out all build tools and reinstalling) please let\nme know. \n* **OS X Users** If you have this message when compiling on OS X (likely Catalina and later),\n```bash\nmc_lexer.yy.cc:675:8: error: member reference type 'std::istream *' (aka 'basic_istream\u003cchar\u003e *') is a\n      pointer; did you mean to use '-\u003e'?\n```\nThen this means that you've a broken cpp path. To see why this is, go to the command line, type\n```bash\ncpp -xc++ -v \u003c /dev/null\n```\nto see your path included by clang. The key problem is the lack of a modern FlexLexer.h in the \ncommand line tools of OS X, which is compouned when you install a new verson of Flex and the \nheader isn't in the path. So, your binary will be the right one, the headers the wrong ones. \nAs an example, the header file we want on my install of OS X (fresh VM install), is in \n```\n/System/Volumes/Data/usr/local/Cellar/flex/2.6.4_1/include/FlexLexer.h\n```\nwhich is installed by _home brew_. Unfortunately, the default include path pulls in the system\ndefault version at \n```\n/System/Volumes/Data/Library/Developer/CommandLineTools/usr/include/FlexLexer.h\n```\n**HOW TO FIX**\n\n    1.  Interestingly there's yet another version in ```/Library/Developer```. So how do you fix? \n    The simplest way if you have sudo access, do:\n    ```\n    sudo -s \n    ln -s \u003cPath to your installed Flex Header\u003e/FlexLexer.h\n    ```\n    As an example, here's my path:  \n    ```\n    ln -s /System/Volumes/Data/usr/local/Cellar/flex/2.6.4_1/include/FlexLexer.h\n    ```\n    2. Second, **best** way for non-root is to set the _CPLUS\\_INCLUDE\\_PATH_ like this\n    ```\n    CPLUS_INCLUDE_PATH=/System/Volumes/Data/usr/local/Cellar/flex/2.6.4_1/include/:$CPLUS_INCLUDE_PATH\n    ```\n    using my path above. \n\n* **Bison Version** - updated the latest head to test with Bison vs. 3.5, there were a few minor \nchanges in syntax, now reflected in the example code. Will no longer work with Bison vs. \u003c 3.3, \nsee notes from [link](https://lwn.net/Articles/777594/).\n\n\nThanks!\n","funding_links":[],"categories":["C++"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonathan-beard%2Fsimple_wc_example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonathan-beard%2Fsimple_wc_example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonathan-beard%2Fsimple_wc_example/lists"}