0

OK, so Bison/Yacc takes its input in yyin as FILE*.

This is my current code (it's in D, but the issue is not that D-related; a C solution would be easily convertible) :

auto file = File(filename, "r");

yyin = file.getFP();
yyparse();

How is it possible to feed it with a string (or a char buffer)?

Dr.Kameleon
  • 22,532
  • 20
  • 115
  • 223
  • Apparently you cannot use a string directly, since there's no equivalent for `std::istringstream` when `FILE*` is used. IMHO the simplest solution would be, to take the string, write it to a temporary file, and use this one as input. – πάντα ῥεῖ May 02 '14 at 11:17
  • 4
    "takes its input in yyin as FILE*." No it doesn't. It consumes tokens returned by yylex(). You write yylex() however you want. If you want yylex() generated by flex, and you want to feed a string to it, see here http://stackoverflow.com/questions/780676/string-input-to-flex-lexer – n. m. could be an AI May 02 '14 at 11:24

0 Answers0