jlab / gapc

Bellman's GAP compiler
GNU General Public License v3.0
7 stars 6 forks source link

use OUTSIDE_ALL #217

Closed sjanssen2 closed 1 year ago

sjanssen2 commented 1 year ago

Hi @fymue can you give me a hint how I can replace the hard coded ALL in the following line with the value of https://github.com/jlab/gapc/blob/06a688dce38b679bdde8f68533d2bdf19bc83715/src/gapc.cc#L110 OUTSIDE_ALL: https://github.com/jlab/gapc/blob/06a688dce38b679bdde8f68533d2bdf19bc83715/src/outside/grammar_transformation.hh#L43 ?

fymue commented 1 year ago

Sure. You can simply wrap the help msg in an std::string and concatenate OUTSIDE_ALL with that string, like so:

("outside_grammar", po::value< std::vector<std::string> >(),
 std::string("generate an outside version of the grammar and report outside results 
 for an inside non-terminal. Provide multiple times for lists of non-terminals or type \" + 
 OUTSIDE_ALL + \" to report results for all non-terminals.").c_str())

I can't tell if OUTSIDE_ALL is going to be visible in gapc.cc though. If not, you could just turn it into a macro.

fymue commented 1 year ago

You also might need to wrap OUTSIDE_ALL in a std::string. I'm not sure if operator+ is overloaded for const char*, so you might not be able to concatenate the strings like this unless one of the strings is an actual std::string.

sjanssen2 commented 1 year ago

it needed to "double wrap", but it works like a charm. Thank you!