summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2015-03-31 18:33:28 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2015-03-31 18:33:28 +0200
commit8b94b9cf2c91e00665771bb46e1d9a6400114e63 (patch)
tree860020b174f10895ab0779e719052630d05ca9cf
parent8e7ce62c2011b725c0f875a86b27e12c5489dae8 (diff)
downloadsolar-8b94b9cf2c91e00665771bb46e1d9a6400114e63.tar
solar-8b94b9cf2c91e00665771bb46e1d9a6400114e63.zip
solar: use grammar file from command line
-rw-r--r--src/solar.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/solar.cpp b/src/solar.cpp
index e0fbba0..c022a6d 100644
--- a/src/solar.cpp
+++ b/src/solar.cpp
@@ -74,11 +74,16 @@ bool read_grammar(const char *filename, parser_state_t *state) {
}
-int main() {
+int main(int argc, char *argv[]) {
using namespace solar;
+ if (argc < 2) {
+ std::fprintf(stderr, "Usage: solar FILE\n");
+ return 1;
+ }
+
parser_state_t state;
- if (!read_grammar("grammar.y", &state))
+ if (!read_grammar(argv[1], &state))
return 1;
generator_t generator(state.get_rules());