fix: specify start, allow parse file as cmd arg
This commit is contained in:
parent
7f11aaf21e
commit
a529b6e3f6
|
|
@ -96,6 +96,8 @@ namespace DragonLisp {
|
||||||
|
|
||||||
%define parse.error verbose
|
%define parse.error verbose
|
||||||
|
|
||||||
|
%start S
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
S
|
S
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,10 @@ DLDriver::~DLDriver() {
|
||||||
|
|
||||||
int DLDriver::parse(const std::string& f) {
|
int DLDriver::parse(const std::string& f) {
|
||||||
std::ifstream in(f);
|
std::ifstream in(f);
|
||||||
if (!in.good())
|
if (!in.good()) {
|
||||||
|
std::printf("Could not open file %s\n", f.c_str());
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
return this->parse(in, f);
|
return this->parse(in, f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
6
main.cpp
6
main.cpp
|
|
@ -2,7 +2,9 @@
|
||||||
|
|
||||||
#include "DragonLispDriver.hh"
|
#include "DragonLispDriver.hh"
|
||||||
|
|
||||||
int main() {
|
int main(int argc, char** argv) {
|
||||||
DragonLisp::DLDriver driver;
|
DragonLisp::DLDriver driver;
|
||||||
return driver.parse(std::cin);
|
if (argc <= 1)
|
||||||
|
return driver.parse(std::cin);
|
||||||
|
return driver.parse(argv[1]);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue