From 3829415d19e17c8e3db5c60eff9fc61ac4a9f0d6 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 26 Dec 2015 14:15:58 -0500 Subject: [PATCH] gr: Added '-d' and '--debug' command line option --- src/gr.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/gr.cpp b/src/gr.cpp index 60257314..b7158668 100644 --- a/src/gr.cpp +++ b/src/gr.cpp @@ -40,6 +40,7 @@ void usage () << "\n" << "Options are:\n" << " -h/--help Command usage\n" + << " -d/--debug Debug mode\n" << "\n"; exit (-1); } @@ -50,6 +51,7 @@ int main (int argc, char** argv) // Process command line arguments std::string grammarFile = ""; std::string commandLine = ""; + bool debug = false; for (int i = 1; i < argc; ++i) { @@ -57,6 +59,8 @@ int main (int argc, char** argv) { if (!strcmp (argv[i], "-h")) usage (); else if (!strcmp (argv[i], "--help")) usage (); + else if (!strcmp (argv[i], "-d")) debug = true; + else if (!strcmp (argv[i], "--debug")) debug = true; else { std::cout << "Unrecognized option '" << argv[i] << "'" << std::endl; @@ -84,6 +88,7 @@ int main (int argc, char** argv) { File file (grammarFile); Grammar grammar; + grammar.debug (debug); grammar.loadFromFile (file); std::cout << grammar.dump (); @@ -91,6 +96,7 @@ int main (int argc, char** argv) if (commandLine != "") { LR0 lr0; + lr0.debug (debug); lr0.createParseTables (grammar); std::cout << lr0.dump ();