354{
355 std::ofstream gramFile(fileName);
356 gramFile << "Start Kind:\n";
358
359 gramFile << "Epsilon Production:\n";
360 std::vector<std::string> strV;
362 {
363 std::stringstream ss;
364 for (auto sym : pro)
365 {
366 if (sym == pro[1])
367 {
368 ss << "-> ";
369 }
370 ss <<
symToStrDump(sym) <<
'(' << sym.kind <<
')' <<
' ';
371 }
372 strV.insert(strV.begin(), ss.str());
373 }
374 std::sort(strV.begin(), strV.end());
375 for (auto pro: strV)
376 {
377 gramFile << '\t';
378 gramFile << pro;
379 gramFile << '\n';
380 }
381 gramFile << '\n';
382
383 gramFile << "Single Production:\n";
384 strV = {};
386 {
387 for (auto pro: symProPair.second)
388 {
389 std::stringstream ss;
390 int i = 0;
391 for (auto sym : pro)
392 {
393 i++;
394 if (i == 2)
395 {
396 ss << "-> ";
397 }
398 ss <<
symToStrDump(sym) <<
'(' << sym.kind <<
')' <<
' ';
399 }
400 strV.insert(strV.begin(), ss.str());
401 }
402 }
403 std::sort(strV.begin(), strV.end());
404 for (auto pro: strV)
405 {
406 gramFile << '\t';
407 gramFile << pro;
408 gramFile << '\n';
409 }
410 gramFile << '\n';
411
412 gramFile << "Binary Production:\n";
413 strV = {};
415 {
416 for (auto pro: symProPair.second)
417 {
418 std::stringstream ss;
419 int i = 0;
420 for (auto sym : pro)
421 {
422 i++;
423
424 if (i == 2)
425 {
426 ss << "-> ";
427 }
428 ss <<
symToStrDump(sym) <<
'(' << sym.kind <<
')' <<
' ';
429 }
430 strV.insert(strV.begin(), ss.str());
431 }
432 }
433 std::sort(strV.begin(), strV.end());
434 for (auto pro: strV)
435 {
436 gramFile << '\t';
437 gramFile << pro;
438 gramFile << '\n';
439 }
440 gramFile << '\n';
441
442 gramFile.close();
443}
SymbolMap< Symbol, Productions > firstRHSToProds
SymbolSet< Production > epsilonProds
SymbolMap< Symbol, Productions > singleRHSToProds
std::string symToStrDump(Symbol sym) const
std::string kindToStr(Kind kind) const