diff --git a/build_debug.sh b/build_debug.sh index e5b5bb1..4480cf6 100755 --- a/build_debug.sh +++ b/build_debug.sh @@ -10,7 +10,8 @@ language=' warnings=' -Wall - -Wextra' + -Wextra + -Wno-implicit-fallthrough' cd src g++ -o ../tft_debug $language -g -O0 -march=native $warnings -pipe *.cpp -lncursesw diff --git a/install.sh b/install.sh index 70eeaf4..aecc5b3 100755 --- a/install.sh +++ b/install.sh @@ -19,7 +19,8 @@ optimizations=' warnings=' -Wall - -Wextra' + -Wextra + -Wno-implicit-fallthrough' # -Wpedantic' #-fanalyzer diff --git a/src/parser.cpp b/src/parser.cpp index a262abd..7432377 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -94,10 +94,12 @@ namespace /* internal */ exit(1); } - [[noreturn]]void err_expected(const char* what) + [[noreturn]]void err_expected(const char* what, token instead) { endwin(); - cerr << "Line " << line << ": Expected " << what << "\n"; + cerr << "Line " << line << ": Expected " << what << "got"; + cerr.write(instead.begin, instead.size()); + cerr << "instead\n"; cerr.flush(); exit(1); } @@ -106,7 +108,9 @@ namespace /* internal */ [[noreturn]]void err_unexpected_token(token t) { endwin(); - /* cerr << "Line " << line << ": Unexpected token '" << c << "'\n"; */ + cerr << "Line " << line << ": Unexpected token '"; + cerr.write(t.begin, t.size()); + cerr << "'\n"; cerr.flush(); exit(1); } @@ -114,19 +118,21 @@ namespace /* internal */ [[noreturn]]void err_illegal_attribute(token attr) { endwin(); - /* cerr << "Line " << line << ": Unexpected '" << c << "'\n"; */ + cerr << "Line " << line << ": Illegal attribute '"; + cerr.write(attr.begin, attr.size()); + cerr << "'\n"; cerr.flush(); exit(1); } - [[noreturn]]void err_thirdParent(const string& extra_name) - { - endwin(); - cerr << "Line " << line << ": two parents are already defined, " - << extra_name << " is third\n"; - cerr.flush(); - exit(1); - } + /* [[noreturn]]void err_thirdParent(const string& extra_name) */ + /* { */ + /* endwin(); */ + /* cerr << "Line " << line << ": two parents are already defined, " */ + /* << extra_name << " is third\n"; */ + /* cerr.flush(); */ + /* exit(1); */ + /* } */ [[noreturn]]void err_personUndefined(const string& name) { @@ -232,7 +238,7 @@ namespace /* internal */ string parseName(TokenIt& it, TokenIt end) { if(it->type != STRING) - err_expected("name"); + err_expected("name", *it); string name; for(; it < end && it->type == STRING; ++it) @@ -287,11 +293,11 @@ namespace /* internal */ else if(it->begin[0] == 'F') res = F; else - err_expected("sex"); + err_expected("sex", *it); ++it; } else - err_expected("sex"); + err_expected("sex", *it); } else @@ -331,7 +337,7 @@ namespace /* internal */ return sign * val; } - EventTime state_date(TokenIt& it, TokenIt end) /* todo validate */ + EventTime state_date(TokenIt& it) /* todo validate */ { ++it; /* skip attribute */ if(it->type == STRING || it->type == NUMBER) @@ -357,7 +363,7 @@ namespace /* internal */ return date; } else - err_expected("date"); + err_expected("date", *it); } @@ -470,10 +476,10 @@ namespace /* internal */ switch(it->begin[0]) { case 'b': - birth = state_date(it, end); /* todo check for redefinition */ + birth = state_date(it); /* todo check for redefinition */ break; case 'd': - death = state_date(it, end); + death = state_date(it); break; case 'p': parents = processParents(it, end); diff --git a/src/utils.cpp b/src/utils.cpp index d9b5aeb..74f1f9c 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -6,8 +6,8 @@ #include #include -static void end() -{ +/* static void end() */ +/* { */ /* printf("before end\n"); */ /* fflush(stdout); */ /* for(int i=0;i < 100;i) */ @@ -15,14 +15,14 @@ static void end() /* printf("before end\n"); */ /* fflush(stdout); */ /* } */ - endwin(); + /* endwin(); */ /* printf("done\n"); */ /* fflush(stdout); */ /* std::cout <<"done\n"<