changed: PatternParser now uses Log from pikotools

git-svn-id: svn://ttmath.org/publicrep/ezc/trunk@1153 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
Tomasz Sowa 2018-11-23 18:33:17 +00:00
parent bf62d44346
commit 1e85922d4e
4 changed files with 43 additions and 24 deletions

View File

@ -16,21 +16,14 @@ all: $(libname)
$(libname): $(o)
ar rcs $(libname) $(o)
additionalinclude =
ifdef EZC_USE_WINIX_LOGGER
additionalinclude = $(EZC_ADDITIONAL_INCLUDE)
endif
%.o: %.cpp
$(CXX) -c $(CXXFLAGS) -I$(GLOBAL_WORKING_DIR)/pikotools $(additionalinclude) $<
$(CXX) -c $(CXXFLAGS) -I$(GLOBAL_WORKING_DIR)/pikotools $<
depend:
# we do not use $(additionalinclude) here because the dependencies would be added to the repository
# and messes other projects
# !! IMPROVE ME
# as Ezc is a different project we rather shoudn't use '-I$(global_relative_working_dir)/pikotools' here?
makedepend -Y. -I$(global_relative_working_dir)/pikotools -f- *.cpp > Makefile.dep

View File

@ -9,8 +9,16 @@ pattern.o: pattern.h item.h cache.h functions.h ../../pikotools/utf8/utf8.h
pattern.o: funinfo.h objects.h blocks.h
patternparser.o: patternparser.h blocks.h item.h cache.h functions.h
patternparser.o: ../../pikotools/utf8/utf8.h funinfo.h objects.h pattern.h
patternparser.o: ../../pikotools/log/log.h
patternparser.o: ../../pikotools/textstream/textstream.h
patternparser.o: ../../pikotools/space/space.h
patternparser.o: ../../pikotools/textstream/types.h
patternparser.o: ../../pikotools/date/date.h
patternparser.o: ../../pikotools/convert/convert.h
patternparser.o: ../../pikotools/convert/inttostr.h
patternparser.o: ../../pikotools/convert/strtoint.h
patternparser.o: ../../pikotools/convert/text.h
patternparser.o: ../../pikotools/convert/misc.h
patternparser.o: ../../pikotools/membuffer/membuffer.h
patternparser.o: ../../pikotools/textstream/types.h
patternparser.o: ../../pikotools/log/filelog.h

View File

@ -39,9 +39,6 @@
#include "patternparser.h"
#include "convert/convert.h"
#ifdef EZC_USE_WINIX_LOGGER
#include "core/log.h"
#endif
namespace Ezc
@ -56,6 +53,7 @@ PatternParser::PatternParser()
include_level_max = 100;
delete_white_text_items = false;
program_mode = false;
log = nullptr;
}
@ -163,6 +161,12 @@ void PatternParser::SetProgramMode(bool program_mode)
}
void PatternParser::SetLogger(PT::Log * log)
{
this->log = log;
}
void PatternParser::CreateMsg(std::wstring & out, const wchar_t * type, const wchar_t * arg)
{
out = commentary_start;
@ -379,12 +383,13 @@ bool PatternParser::ReadFileFromDir(const std::wstring & dir, const wchar_t * na
return false;
}
#ifdef EZC_USE_WINIX_LOGGER
if( include_level <= 1 )
Winix::log << Winix::log3 << "Ezc: reading pattern: " << afile_name << Winix::logend;
else
Winix::log << Winix::log3 << " including pattern: " << afile_name << Winix::logend;
#endif
if( log )
{
if( include_level <= 1 )
(*log) << PT::Log::log4 << "Ezc: reading pattern: " << afile_name << PT::Log::logend;
else
(*log) << PT::Log::log4 << " including pattern: " << afile_name << PT::Log::logend;
}
ReadFile(file, result);
@ -1029,10 +1034,17 @@ return false;
void PatternParser::CreateTreeReadInclude(Item & item)
{
if( !allow_include )
return;
CreateTreeReadIncludeSkipAllowFlag(item);
if( allow_include )
{
CreateTreeReadIncludeSkipAllowFlag(item);
}
else
{
if( log )
{
(*log) << PT::Log::log2 << "Ezc: \"include\" directive is not allowed" << PT::Log::logend;
}
}
}
@ -1045,9 +1057,10 @@ void PatternParser::CreateTreeReadIncludeSkipAllowFlag(Item & item)
if( include_level > include_level_max )
{
#ifdef EZC_USE_WINIX_LOGGER
Winix::log << Winix::log1 << "Ezc: \"include\" directive has reached the maximum level" << Winix::logend;
#endif
if( log )
{
(*log) << PT::Log::log1 << "Ezc: \"include\" directive has reached the maximum level" << PT::Log::logend;
}
return;
}

View File

@ -42,6 +42,7 @@
#include "blocks.h"
#include "pattern.h"
#include "utf8/utf8.h"
#include "log/log.h"
namespace Ezc
@ -88,6 +89,8 @@ public:
void SetProgramMode(bool program_mode);
void SetLogger(PT::Log * log);
private:
// the output object
@ -135,6 +138,8 @@ private:
bool program_mode;
PT::Log * log;
void CreateMsg(std::wstring & out, const wchar_t * type, const wchar_t * arg = 0);
void ReadFile(const std::wstring & name, std::wstring & result);