All Projects → jonathan-beard → Simple_wc_example

jonathan-beard / Simple_wc_example

Licence: apache-2.0
simple word count example using flex/bison parser

Projects that are alternatives of or similar to Simple wc example

Crawlertutorial
爬蟲極簡教學(fetch, parse, search, multiprocessing, API)- PTT 為例
Stars: ✭ 282 (+176.47%)
Mutual labels:  parse, tutorial
flex-bison-indentation
An example of how to correctly parse python-like indentation-scoped files using flex (and bison).
Stars: ✭ 32 (-68.63%)
Mutual labels:  flex, parse
Keras Tutorial
Tutorial teaching the basics of Keras and some deep learning concepts
Stars: ✭ 98 (-3.92%)
Mutual labels:  tutorial
Atis.keras
Spoken Language Understanding(SLU)/Slot Filling in Keras
Stars: ✭ 100 (-1.96%)
Mutual labels:  tutorial
Recommenders
Best Practices on Recommendation Systems
Stars: ✭ 11,818 (+11486.27%)
Mutual labels:  tutorial
Python For Absolute Beginners Course
Code samples and other handouts for our course.
Stars: ✭ 1,352 (+1225.49%)
Mutual labels:  tutorial
Serverless With Next5 Boilerplate
Serverless.js with Next.js 5 on AWS, powered by the Serverless Framework
Stars: ✭ 100 (-1.96%)
Mutual labels:  tutorial
Swiftcrossplatformframework
Tutorial to create cross platform framework for Swift compatible with Carthage and SwiftPM
Stars: ✭ 98 (-3.92%)
Mutual labels:  tutorial
Scipy2017 Jupyter Widgets Tutorial
Notebooks for the SciPy 2017 tutorial "The Jupyter Interactive Widget Ecosystem"
Stars: ✭ 102 (+0%)
Mutual labels:  tutorial
No Framework Tutorial
A small tutorial to show how to create a PHP application without a framework.
Stars: ✭ 1,357 (+1230.39%)
Mutual labels:  tutorial
Cookbook.fish
Tips and recipes for Fish, from shell to plate. 🍣
Stars: ✭ 1,360 (+1233.33%)
Mutual labels:  tutorial
Date And Time
A Minimalist DateTime utility for Node.js and the browser
Stars: ✭ 99 (-2.94%)
Mutual labels:  parse
30 Days Of Python 3.6
This is a soon-to-be archived project version of 30 Days of Python. The original tutorial still works but we have an updated version in the works right now.
Stars: ✭ 98 (-3.92%)
Mutual labels:  tutorial
Circleci Demo Python Django
Example Django application running on CircleCI
Stars: ✭ 100 (-1.96%)
Mutual labels:  tutorial
Pfincrementalstore
Offline Parse with Core Data Persistence, an NSIncrementalStore subclass.
Stars: ✭ 98 (-3.92%)
Mutual labels:  parse
Gainlo Interview Guide Zh
📖 [译] Gainlo 面试指南
Stars: ✭ 100 (-1.96%)
Mutual labels:  tutorial
Easy Yolo
Yolo (Real time object detection) model training tutorial with deep learning neural networks
Stars: ✭ 98 (-3.92%)
Mutual labels:  tutorial
Jni By Examples
🎇Fun Java JNI By Examples - with CMake and C++ (or C, of course!) ‼️ Accepting PRs
Stars: ✭ 99 (-2.94%)
Mutual labels:  tutorial
Tutorials cn
Stars: ✭ 100 (-1.96%)
Mutual labels:  tutorial
Pythonpersiantutorial
A free and online Python book in Persian
Stars: ✭ 102 (+0%)
Mutual labels:  tutorial

Simple Word Count Parser Example

=================

Build Status

Tested on linux and OS X

Build Status

About

So this is a super simple parser example. The tutorial is located here: link

Between the tutorial and the code you should be able to get started with more advanced projects using C++ and Flex/Bison. Admittedly the example itself is a bit contrived, however it's mean to be simple and get the point across. If there are changes in Flex/Bison that prevent the example from compiling or if you just have improvements, feel free to generate a pull request or just shoot me an e-mail.

To compile just download and run make, there's a super simple test harness to make sure it runs in the test dir.

Or you use CMake.

mkdir build/
cmake ..
make

or with clang

mkdir build/
CC=clang CXX=clang++ cmake ..
make

or with clang with optimisations

mkdir build/
CC=clang CXX=clang++ cmake .. -DCMAKE_BUILD_TYPE=Release
make

To run the simple test after make call

ctest

NOTES

  • OS X Users I've heard of some issues compiling if you've installed command line tools, then XCode.app afterwards on Catalina (with bash). When compiling with clang++, the C++ header files aren't found. If you have this issue, exporting an environment variable, such as this, export CXX=/usr/bin/clang++, seems to be a workaround. If anybody has a better solution (aside from wiping out all build tools and reinstalling) please let me know.
  • OS X Users If you have this message when compiling on OS X (likely Catalina and later),
mc_lexer.yy.cc:675:8: error: member reference type 'std::istream *' (aka 'basic_istream<char> *') is a
      pointer; did you mean to use '->'?

Then this means that you've a broken cpp path. To see why this is, go to the command line, type

cpp -xc++ -v < /dev/null

to see your path included by clang. The key problem is the lack of a modern FlexLexer.h in the command line tools of OS X, which is compouned when you install a new verson of Flex and the header isn't in the path. So, your binary will be the right one, the headers the wrong ones. As an example, the header file we want on my install of OS X (fresh VM install), is in

/System/Volumes/Data/usr/local/Cellar/flex/2.6.4_1/include/FlexLexer.h

which is installed by home brew. Unfortunately, the default include path pulls in the system default version at

/System/Volumes/Data/Library/Developer/CommandLineTools/usr/include/FlexLexer.h

HOW TO FIX

1.  Interestingly there's yet another version in ```/Library/Developer```. So how do you fix? 
The simplest way if you have sudo access, do:
```
sudo -s 
ln -s <Path to your installed Flex Header>/FlexLexer.h
```
As an example, here's my path:  
```
ln -s /System/Volumes/Data/usr/local/Cellar/flex/2.6.4_1/include/FlexLexer.h
```
2. Second, **best** way for non-root is to set the _CPLUS\_INCLUDE\_PATH_ like this
```
CPLUS_INCLUDE_PATH=/System/Volumes/Data/usr/local/Cellar/flex/2.6.4_1/include/:$CPLUS_INCLUDE_PATH
```
using my path above. 
  • Bison Version - updated the latest head to test with Bison vs. 3.5, there were a few minor changes in syntax, now reflected in the example code. Will no longer work with Bison vs. < 3.3, see notes from link.

Thanks!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].