1

I am using Flexc++ and Bisonc++ to implement a small language.

Flexc++ provides a simple constructor

Scanner(std::string const &infile, std::string const &outfile) 

to set the input and output files.

However, when integrating with Bisconc++ I cannot find a simple way to use this constructor for the scanner object inside the generated parser.

The auto-generated Parser.h contains the scanner object:

...
Scanner d_scanner;
....

By default, the parser class has no constructor with input/output arguments and the parse-function has no parameters. Default behavior is parsing from standard input and outputting to standard output.

What I seek is basically the same as this question (see 2.) but the answers do not really cover this criteria.

At the moment I parse from standard input with

int main(....) {
  Parser parser;
  parser.parse()
}

Instead I will like to specify a file-path and provide it to the parse-function or even to the constructor.

int main(....) {
  std::string filePath;
  Parser parser; // or (filePath) here 
  parser.parse(filePath)
}

Of course I could just add the functionality after parser generation, but that is not really the best option as everything should be auto-generated.

I fail to see how to do this with the provided .ih header files.

And yes, I want to use Flexc++ and Bisonc++.

Community
  • 1
  • 1
User
  • 229
  • 3
  • 11
  • What do you mean when you say you "cannot find a simple way to use this constructor for the scanner object inside the generated parser"? Can you please elaborate? And show us what you have tried, and tell us what problems you have with your attempt? – Some programmer dude Mar 13 '17 at 08:47

0 Answers0