Skip to content

Commit

Permalink
Implement correct_differ and correct_cover
Browse files Browse the repository at this point in the history
  • Loading branch information
kovzol committed Jan 19, 2025
1 parent 22c25d3 commit a15944a
Show file tree
Hide file tree
Showing 5 changed files with 131 additions and 61 deletions.
4 changes: 2 additions & 2 deletions cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <vector>

#ifdef WITH_PBRST
extern "C" char* brst_scan_string(char *string, int correct_raw, int show_dump);
extern "C" char* brst_scan_string(char *string, int correct_raw, int correct_differ, int correct_cover, int show_dump);
// #include "statements/pbrst.tab.h" // use flex/bison parser for bibref statements (brst)
#include "pbrst.tab.h" // the statements folder must be included among the folders
#endif
Expand Down Expand Up @@ -852,7 +852,7 @@ void processGetrefsCmd(string input) {

#ifdef WITH_PBRST
void processStatementCmd(string input) {
char *output = brst_scan_string((char*)input.c_str(), 0, 0);
char *output = brst_scan_string((char*)input.c_str(), 0, 0, 0, 0);
string output_s(output);
vector<string> statementAnalysis;
boost::split(statementAnalysis, output_s, boost::is_any_of("\n"));
Expand Down
4 changes: 2 additions & 2 deletions qt/statementwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <boost/algorithm/string/predicate.hpp>
#include <boost/algorithm/string/split.hpp>

extern "C" char* brst_scan_string(char *string, int correct_raw, int show_dump);
extern "C" char* brst_scan_string(char *string, int correct_raw, int correct_differ, int correct_cover, int show_dump);
#include "pbrst.tab.h" // the statements folder must be included among the folders

using namespace std;
Expand Down Expand Up @@ -93,7 +93,7 @@ void StatementWindow::setupFileMenu()
void StatementWindow::parse()
{
#ifdef WITH_PBRST
char* output = brst_scan_string((char*)editor->toPlainText().toStdString().c_str(), 0, 0);
char* output = brst_scan_string((char*)editor->toPlainText().toStdString().c_str(), 0, 0, 0, 0);
string output_s(output);
vector<string> statementAnalysis;
boost::split(statementAnalysis, output_s, boost::is_any_of("\n"));
Expand Down
32 changes: 24 additions & 8 deletions statements/pbrst-cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,52 +61,68 @@ int main(int ac, char **av)
{
extern FILE *yyin;
extern int correct_raw;
extern int correct_differ;
extern int correct_cover;
extern int show_dump;

bool colorize = false;
bool graphviz = false;
correct_raw = 0;
correct_differ = 0;
correct_cover = 0;
show_dump = 0;
bool show_only_dump = false;

while (ac>1 && (!strcmp(av[1], "-d") || !strcmp(av[1], "-c")
|| !strcmp(av[1], "-g") || !strcmp(av[1], "-r") || !strcmp(av[1], "-h")
|| !strcmp(av[1], "-g") || !strcmp(av[1], "-r")
|| !strcmp(av[1], "-D") || !strcmp(av[1], "-C")
|| !strcmp(av[1], "-h")
|| !strcmp(av[1], "-u") || !strcmp(av[1], "-U"))) {

if(!strcmp(av[1], "-h")) {
if (!strcmp(av[1], "-h")) {
printf("pbrst-cli [options] [input.brst], a command line brst parser\n");
printf("Options:\n");
printf(" -h\tthis help\n");
printf(" -d\tswitch debug mode on\n");
printf(" -c\tcolorize output\n");
printf(" -g\tshow only graphviz output\n");
printf(" -r\tcorrect raw positions\n");
printf(" -D\tcorrect differings\n");
printf(" -C\tcorrect coverings\n");
printf(" -u\tshow BRST dump\n");
printf(" -U\tshow only BRST dump\n");
exit(0);
}

if(!strcmp(av[1], "-d")) {
if (!strcmp(av[1], "-d")) {
yydebug = 1; ac--; av++;
}

if(!strcmp(av[1], "-c")) {
if (!strcmp(av[1], "-c")) {
colorize = true; ac--; av++;
}

if(!strcmp(av[1], "-g")) {
if (!strcmp(av[1], "-g")) {
graphviz = true; ac--; av++;
}

if(!strcmp(av[1], "-r")) {
if (!strcmp(av[1], "-r")) {
correct_raw = 1; ac--; av++;
}

if(!strcmp(av[1], "-u")) {
if (!strcmp(av[1], "-D")) {
correct_differ = 1; ac--; av++;
}

if (!strcmp(av[1], "-C")) {
correct_cover = 1; ac--; av++;
}

if (!strcmp(av[1], "-u")) {
show_dump = 1; ac--; av++;
}

if(!strcmp(av[1], "-U")) {
if (!strcmp(av[1], "-U")) {
show_dump = 1; show_only_dump = true; ac--; av++;
}

Expand Down
Loading

0 comments on commit a15944a

Please sign in to comment.