Closed deemaalomair1 closed 4 years ago
Hi. I'll try to help out if possible. I'm not an xcode user for the most part, so...will have to wing it a bit.
To start, have you tried building the generator for an xcode understandable build configuration file from cmake? To do this from scratch, you'd do the following:
If you **don't have cmake installed***, follow instructions here: homebrew then open the terminal and type
brew install cmake
make sure cmake is in your path, then you can go to the next step, where you reclone the repo (just in case it's been modified, it's easier to start with an unmodified copy). Do the following from the terminal:
git clone https://github.com/jonathan-beard/simple_wc_example.git
cd smple_wc_example
cmake -G Xcode .
From there, close any currently open projects, then re-open the simple_wc_example repo with it's now recognizable xcode generated project file. This should allow you to run directly from xcode.
From a C++ perspective, the scanner is a sub-class of yyFlexLexer. The reason we want to subclass, is primarily so we can inject state cleanly with the sub-class's private variables. You can likely technically get away without having to do this, however, it's easier in the long run to just make s sub-class. If you look at the Raft language I started to put together a long time ago you can see an example of adding extra state through the sub-class. Another thing to keep in mind as you're thinking about sub-classes is that when you do so, you must tell flex the sub-class name in a few places, most importantly here:
%option yyclass="MC::MC_Scanner"
I'll leave this one open for now, let us know if this works!
-J
thank you for your prompt helpful reply .
i did what you said and now i have Xcode project without issues, but when i run the project nothing happen !
to be honest my problem is i have c++ project written in Xcode with sets of classes and functions. then a added a rule language in pasrer.ypp file inside my project + lexer.lpp . now i would like to make the parser execute one of the function if the entered input matches the rule. like what did you do in your mc_parser.y file when its call (driver.add_upper();) function if rule UPPER . but i do not know what i need to add in each file where to include parser and i feel lost !
sent you an example via email. closing.
hello dear,
I am trying to run your project in my Xcode .. but it gives me error in mc_scanner.hpp file when i include the followings:
include "mc_parser.tab.hh"
include "location.hh"
'mc_parser.tab.hh' file not found..
I know I have missed something .. but I am too beginner in parser (this is my first time to use it). I would like to know what is the main use of mc_scanner.hpp file ? and how can i avoid this kind of error
i read your page http://www.jonathanbeard.io/tutorials/FlexBisonC++ that describes all the project but still did not get the idea of having mc_scanner very well.
I try to run the project after adding all files into new Xcode project by this commands: bison -d -o mc_parser.tab.cpp mc_parser.ypp
flex -o mc_lexer.yy.cpp mc_lexer.lpp
g++ -o last mc_parser.tab.cpp mc_lexer.yy.cpp
I really appreciate your help.
best regards,