Skip to content

Commit

Permalink
Implement dump
Browse files Browse the repository at this point in the history
  • Loading branch information
kovzol committed Jan 18, 2025
1 parent ede7b5f commit 3918e56
Show file tree
Hide file tree
Showing 4 changed files with 172 additions and 31 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);
extern "C" char* brst_scan_string(char *string, int correct_raw, 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());
char *output = brst_scan_string((char*)input.c_str(), 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);
extern "C" char* brst_scan_string(char *string, int correct_raw, 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());
char* output = brst_scan_string((char*)editor->toPlainText().toStdString().c_str(), 0, 0);
string output_s(output);
vector<string> statementAnalysis;
boost::split(statementAnalysis, output_s, boost::is_any_of("\n"));
Expand Down
13 changes: 12 additions & 1 deletion statements/pbrst-cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,16 @@ int main(int ac, char **av)
{
extern FILE *yyin;
extern int correct_raw;
extern int show_dump;

bool colorize = false;
bool graphviz = false;
correct_raw = 0;
show_dump = 0;

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], "-h")
|| !strcmp(av[1], "-u"))) {

if(!strcmp(av[1], "-h")) {
printf("pbrst-cli [options] [input.brst], a command line brst parser\n");
Expand All @@ -77,6 +80,7 @@ int main(int ac, char **av)
printf(" -c\tcolorize output\n");
printf(" -g\tshow only graphviz output\n");
printf(" -r\tcorrect raw positions\n");
printf(" -u\tshow BRST dump\n");
exit(0);
}

Expand All @@ -96,6 +100,10 @@ int main(int ac, char **av)
correct_raw = 1; ac--; av++;
}

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

}

if(ac > 1 && (yyin = fopen(av[1], "r")) == NULL) {
Expand All @@ -110,6 +118,9 @@ int main(int ac, char **av)
if (strstr(parseinfo, ": error: ") == NULL) {
create_diagram();
}
if (show_dump == 1) {
create_dump();
}
if (graphviz) {
char *g_start = strstr(parseinfo, "diagram: graphviz: start\n");
if (g_start == NULL) exit(0); // empty output
Expand Down
Loading

0 comments on commit 3918e56

Please sign in to comment.