Skip to content

Commit

Permalink
improve a tiny bit testbisoncp.yy & added testb.hh
Browse files Browse the repository at this point in the history
  • Loading branch information
bstarynk committed Mar 21, 2023
1 parent d25d34b commit 7fc5c28
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 3 deletions.
14 changes: 11 additions & 3 deletions ExBisonCpp/maintestb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,19 @@
// ©2023 CEA and Basile Starynkevitch <[email protected]> and
// <[email protected]>

#include <iostream>
#include <unistd.h>
#include <time.h>
#include "testb.hh"


void tb_fatal_error_at(const char*fil, int lin)
{
std::clog << progname << " ***°°°*** FATAL ERROR AT " << fil << ":" << lin
<< std::endl;
abort();
} // end tb_fatal_error_at

int
main(int argc, char**argv)
{
progname = argv[0];
gethostname(myhost, sizeof(myhost));
} // end main
54 changes: 54 additions & 0 deletions ExBisonCpp/testb.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/// file misc-basile/ExBisonCpp/testb.hh

#include <fstream>
#include <iostream>
#include <ostream>
#include <sstream>
#include <cstring>
#include <map>
#include <string>
#include <memory>
#include <iostream>
#include <unistd.h>
#include <time.h>

#include <unistd.h>
#include <assert.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <getopt.h>

char myhost[80];
const char*progname;
extern "C" [[noreturn]] void tb_fatal_error_at(const char*fil, int lin);
#define TB_FATAL_AT(Fil,Lin,Log) do { \
std::ostringstream out##Lin; \
out##Lin << Log << std::endl; \
std::clog << "FATAL ERROR (" << progname << ") " \
<< Log << std::endl; \
tb_fatal_error_at(Fil,Lin); \
} while(0)

#define TB_BISFATAL_AT(Fil,Lin,Log) TB_FATAL_AT((Fil),Lin,Log)

#define TB_FATAL(Log) TB_BISFATAL_AT(__FILE__,__LINE__,Log)


class TbParser {
#warning missing code for class TbParser;
std::string tbpars_source;
public:
TbParser(std::string src): tbpars_source(src) {
};
virtual ~TbParser() {
};
virtual void output(std::ostream&out);
};

inline std::ostream& operator << (std::ostream&out, TbParser&tbp) {
tbp.outpout(out);
return out;
};
// ©2023 CEA and Basile Starynkevitch <[email protected]> and
// <[email protected]>
12 changes: 12 additions & 0 deletions ExBisonCpp/testbisoncp.yy
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,20 @@
// ©2023 CEA and Basile Starynkevitch <[email protected]> and
// <[email protected]>

%thread-safe
%error-verbose
%baseclass-preinclude "testb.hh"
%class-header "_tb-parser.h"
%implementation-header "_tb-parsimpl.h"
%class-name "TbParser"
%debug
%polymorphic
%print-tokens
%% ///// this part has grammar rules

%start input

input: // empty
;

///// end of file misc-basile/ExBisonCpp/testbisoncp.yy

0 comments on commit 7fc5c28

Please sign in to comment.