1
0
mirror of https://github.com/stefanocasazza/ULib.git synced 2025-09-28 19:05:55 +08:00
ULib/include/ulib/flex/bison.h
stefanocasazza 877766b00d bug fixing
2015-07-10 19:16:37 +02:00

98 lines
1.7 KiB
C++

// ============================================================================
//
// = LIBRARY
// ULib - c++ library
//
// = FILENAME
// bison.h
//
// = AUTHOR
// Stefano Casazza
//
// ============================================================================
#ifndef U_BISON_H
#define U_BISON_H
#include <ulib/flex/flexer.h>
/**
* @class UBison
*
* Implementazione of Bison for ULib
*/
// extern int yydebug;
extern int yyparse(void*);
class U_EXPORT UBison : public UFlexer {
public:
// COSTRUTTORI
UBison()
{
U_TRACE_REGISTER_OBJECT(0, UBison, "", 0)
}
UBison(const UString& data_) : UFlexer(data_)
{
U_TRACE_REGISTER_OBJECT(0, UBison, "%V", data_.rep)
}
~UBison()
{
U_TRACE_UNREGISTER_OBJECT(0, UBison)
}
// VARIE
bool parse(void* obj = 0)
{
U_TRACE(0, "UBison::parse(%p)", obj)
U_INTERNAL_ASSERT(data)
// yydebug = 1;
if (obj == 0) obj = this;
if (yyparse(obj) == 0)
{
U_INTERNAL_DUMP("UFlexer::parsed_chars = %d, UFlexer::data.size() = %u", UFlexer::parsed_chars, UFlexer::data.size())
U_RETURN(true);
}
U_RETURN(false);
}
bool parse(const UString& _data, void* obj = 0)
{
U_TRACE(0, "UBison::parse(%V,%p)", _data.rep, obj)
setData(_data);
if (parse(obj)) U_RETURN(true);
U_RETURN(false);
}
// DEBUG
#if defined(U_STDCPP_ENABLE) && defined(DEBUG)
const char* dump(bool reset) const;
#endif
private:
#ifdef U_COMPILER_DELETE_MEMBERS
UBison(const UBison&) = delete;
UBison& operator=(const UBison&) = delete;
#else
UBison(const UBison&) : UFlexer() {}
UBison& operator=(const UBison&) { return *this; }
#endif
};
#endif