Merge branch 'api2021'

This commit is contained in:
Tomasz Sowa 2021-07-06 22:46:36 +02:00
commit 9f416d31de
11 changed files with 1653 additions and 382 deletions

21
.editorconfig Normal file
View File

@ -0,0 +1,21 @@
# EditorConfig
# https://editorconfig.org/
# https://editorconfig-specification.readthedocs.io/
# top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
# 4 space indentation
[*.{h,cpp,html,css,js,conf,txt}]
indent_style = tab
indent_size = 4
# Tab indentation (no size specified)
[Makefile]
indent_style = tab
indent_size = 4

View File

@ -1,8 +1,40 @@
# DO NOT DELETE
blocks.o: blocks.h item.h cache.h functions.h funinfo.h objects.h
cache.o: cache.h item.h functions.h funinfo.h objects.h blocks.h
blocks.o: blocks.h item.h cache.h functions.h ../../pikotools/src/utf8/utf8.h
blocks.o: ../../pikotools/src/textstream/stream.h
blocks.o: ../../pikotools/src/utf8/utf8_templates.h
blocks.o: ../../pikotools/src/utf8/utf8_private.h funinfo.h objects.h
cache.o: cache.h item.h functions.h ../../pikotools/src/utf8/utf8.h
cache.o: ../../pikotools/src/textstream/stream.h
cache.o: ../../pikotools/src/utf8/utf8_templates.h
cache.o: ../../pikotools/src/utf8/utf8_private.h funinfo.h objects.h blocks.h
item.o: item.h
pattern.o: pattern.h item.h cache.h functions.h funinfo.h objects.h blocks.h
models.o: models.h
pattern.o: pattern.h item.h cache.h functions.h
pattern.o: ../../pikotools/src/utf8/utf8.h
pattern.o: ../../pikotools/src/textstream/stream.h
pattern.o: ../../pikotools/src/utf8/utf8_templates.h
pattern.o: ../../pikotools/src/utf8/utf8_private.h funinfo.h objects.h
pattern.o: blocks.h
patternparser.o: patternparser.h blocks.h item.h cache.h functions.h
patternparser.o: funinfo.h objects.h pattern.h
patternparser.o: ../../pikotools/src/utf8/utf8.h
patternparser.o: ../../pikotools/src/textstream/stream.h
patternparser.o: ../../pikotools/src/utf8/utf8_templates.h
patternparser.o: ../../pikotools/src/utf8/utf8_private.h funinfo.h objects.h
patternparser.o: pattern.h ../../pikotools/src/log/log.h
patternparser.o: ../../pikotools/src/textstream/textstream.h
patternparser.o: ../../pikotools/src/textstream/stream.h
patternparser.o: ../../pikotools/src/space/space.h
patternparser.o: ../../pikotools/src/textstream/types.h
patternparser.o: ../../pikotools/src/convert/inttostr.h
patternparser.o: ../../pikotools/src/date/date.h
patternparser.o: ../../pikotools/src/membuffer/membuffer.h
patternparser.o: ../../pikotools/src/textstream/types.h
patternparser.o: ../../pikotools/src/log/filelog.h
patternparser.o: ../../pikotools/src/convert/convert.h
patternparser.o: ../../pikotools/src/convert/inttostr.h
patternparser.o: ../../pikotools/src/convert/patternreplacer.h
patternparser.o: ../../pikotools/src/convert/strtoint.h
patternparser.o: ../../pikotools/src/convert/text.h
patternparser.o: ../../pikotools/src/convert/misc.h
patternparser.o: ../../pikotools/src/convert/double.h

View File

@ -1 +1 @@
o = blocks.o cache.o item.o pattern.o patternparser.o
o = blocks.o cache.o item.o models.o pattern.o patternparser.o

View File

@ -172,9 +172,14 @@ struct FunInfo
bool is_for;
// indicates that this function is from [if ...] statement
// it is true for all kind of if's: if-one, if-any, if-no....
bool is_if;
// indicates that this function is from [if-def ...] statement
bool is_if_def;
// indicates that this function is from [if-not-def ...] statement
bool is_if_not_def;
// indicates that this funcion is a normal statement e.g.: [funcion_name]
bool is_normal;
@ -221,6 +226,8 @@ struct FunInfo
res = false; // result is false by default
is_for = false;
is_if = false;
is_if_def = false;
is_if_not_def = false;
is_normal = false;
is_filter = false;
iter = 0;

File diff suppressed because it is too large Load Diff

View File

@ -53,7 +53,7 @@ struct Item
{
enum Type
{
item_none, item_container, item_text, item_function, item_if,
item_none, item_container, item_text, item_function, item_if, item_if_def, item_if_not_def,
item_for, item_else, item_end, item_err, item_include, item_comment,
item_def, item_def_if_not_set, item_let, item_let_if_not_set,
item_filter, item_ezc, item_block, item_return
@ -64,6 +64,7 @@ struct Item
{
bool is_function; // if true then we have a function parameter, if false then we have a string parameter
std::wstring name; // a function or parameter name
std::vector<std::wstring> fields; // any number of additional fields after a dot e.g. [name.field1.field2]
std::wstring postfix; // a function can have an additional postfix in its name
// e.g. [my_function:my_postfix]
std::vector<Function*> parameters; // if is_function is true then it is a function and can have 'parameters'
@ -123,6 +124,7 @@ struct Item
for(size_t i=0 ; i<parameters.size() ; ++i)
delete parameters[i];
fields.clear();
parameters.clear();
name.clear();
postfix.clear();

133
src/models.cpp Normal file
View File

@ -0,0 +1,133 @@
/*
* This file is a part of EZC -- Easy templating in C++ library
* and is distributed under the BSD 3-Clause licence.
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
/*
* Copyright (c) 2021, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name Tomasz Sowa nor the names of contributors to this
* project may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "models.h"
#ifdef EZC_HAS_MORM_LIBRARY
namespace Ezc
{
Models::Models()
{
}
Models::~Models()
{
Clear();
}
void Models::Clear()
{
models_map.clear();
}
void Models::Add(const std::wstring & name, morm::Model & model)
{
morm::Wrapper wrapper;
wrapper.model = &model;
models_map[name] = wrapper;
}
void Models::Add(const std::wstring & name, morm::Model * model)
{
morm::Wrapper wrapper;
wrapper.model = model;
models_map[name] = wrapper;
}
void Models::Add(const std::wstring & name, pt::Space & space)
{
morm::Wrapper wrapper;
wrapper.space_wrapper = new morm::SpaceWrapper(&space);
models_map[name] = wrapper;
}
void Models::Add(const std::wstring & name, pt::Space * space)
{
morm::Wrapper wrapper;
wrapper.space_wrapper = new morm::SpaceWrapper(space);
models_map[name] = wrapper;
}
void Models::Add(const std::wstring & name, pt::Date & date)
{
morm::Wrapper wrapper;
wrapper.date = &date;
models_map[name] = wrapper;
}
void Models::Add(const std::wstring & name, pt::Date * date)
{
morm::Wrapper wrapper;
wrapper.date = date;
models_map[name] = wrapper;
}
morm::Wrapper * Models::Find(const std::wstring & name)
{
auto iterator = models_map.find(name);
if( iterator != models_map.end() )
{
return &iterator->second;
}
return nullptr;
}
}
#endif

148
src/models.h Normal file
View File

@ -0,0 +1,148 @@
/*
* This file is a part of EZC -- Easy templating in C++ library
* and is distributed under the BSD 3-Clause licence.
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
/*
* Copyright (c) 2021, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name Tomasz Sowa nor the names of contributors to this
* project may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef headerfile_ezc_models
#define headerfile_ezc_models
#ifdef EZC_HAS_MORM_LIBRARY
#include "wrapper.h"
#include "funinfo.h"
#include "space/space.h"
namespace Ezc
{
class Models
{
public:
Models();
~Models();
void Add(const std::wstring & name, morm::Model & model);
void Add(const std::wstring & name, morm::Model * model);
void Add(const std::wstring & name, pt::Space & space);
void Add(const std::wstring & name, pt::Space * space);
void Add(const std::wstring & name, pt::Date & space);
void Add(const std::wstring & name, pt::Date * space);
template<typename VectorType>
void Add(const std::wstring & name, std::vector<VectorType> & container)
{
morm::Wrapper wrapper;
wrapper.model_container_wrapper = new morm::ModelWrapperVector<VectorType>(&container);
models_map[name] = wrapper;
}
template<typename VectorType>
void Add(const std::wstring & name, std::vector<VectorType> * container)
{
morm::Wrapper wrapper;
wrapper.model_container_wrapper = new morm::ModelWrapperVector<VectorType>(container);
models_map[name] = wrapper;
}
template<typename VectorType>
void Add(const std::wstring & name, std::vector<VectorType*> & container)
{
morm::Wrapper wrapper;
wrapper.model_container_wrapper = new morm::ModelWrapperVectorPointer<VectorType>(&container);
models_map[name] = wrapper;
}
template<typename VectorType>
void Add(const std::wstring & name, std::vector<VectorType*> * container)
{
morm::Wrapper wrapper;
wrapper.model_container_wrapper = new morm::ModelWrapperVectorPointer<VectorType>(container);
models_map[name] = wrapper;
}
template<typename ListType>
void Add(const std::wstring & name, std::list<ListType> & container)
{
morm::Wrapper wrapper;
wrapper.model_container_wrapper = new morm::ModelWrapperList<ListType>(&container);
models_map[name] = wrapper;
}
template<typename ListType>
void Add(const std::wstring & name, std::list<ListType> * container)
{
morm::Wrapper wrapper;
wrapper.model_container_wrapper = new morm::ModelWrapperList<ListType>(container);
models_map[name] = wrapper;
}
template<typename ListType>
void Add(const std::wstring & name, std::list<ListType*> & container)
{
morm::Wrapper wrapper;
wrapper.model_container_wrapper = new morm::ModelWrapperListPointer<ListType>(&container);
models_map[name] = wrapper;
}
template<typename ListType>
void Add(const std::wstring & name, std::list<ListType*> * container)
{
morm::Wrapper wrapper;
wrapper.model_container_wrapper = new morm::ModelWrapperListPointer<ListType>(container);
models_map[name] = wrapper;
}
morm::Wrapper * Find(const std::wstring & name);
void Clear();
protected:
std::map<std::wstring, morm::Wrapper> models_map;
};
}
#endif
#endif

View File

@ -150,8 +150,8 @@ void OutStreams<StreamType>::ClearMap()
{
StreamType & str = *(i->second);
#ifdef EZC_HAS_SPECIAL_STREAM
str.Clear();
#ifdef EZC_GENERATOR_HAS_PT_STREAM
str.clear();
#else
str.str(L"");
#endif

View File

@ -124,37 +124,6 @@ void PatternParser::SetBlocks(Blocks & blocks)
}
void PatternParser::SetCommentary(const char * com_start, const char * com_stop)
{
pt::utf8_to_wide(com_start, commentary_start);
pt::utf8_to_wide(com_stop, commentary_stop);
}
void PatternParser::SetCommentary(const std::string & com_start, const std::string & com_stop)
{
pt::utf8_to_wide(com_start, commentary_start);
pt::utf8_to_wide(com_stop, commentary_stop);
}
void PatternParser::SetCommentary(const wchar_t * com_start, const wchar_t * com_stop)
{
commentary_start = com_start;
commentary_stop = com_stop;
}
void PatternParser::SetCommentary(const std::wstring & com_start, const std::wstring & com_stop)
{
commentary_start = com_start;
commentary_stop = com_stop;
}
void PatternParser::SetProgramMode(bool program_mode)
{
this->program_mode = program_mode;
@ -167,19 +136,26 @@ void PatternParser::SetLogger(pt::Log * log)
}
void PatternParser::CreateMsg(std::wstring & out, const wchar_t * type, const wchar_t * arg)
void PatternParser::InitializeEnvTab()
{
out = commentary_start;
out += L"Ezc: ";
out += type;
env_tab.clear();
if( arg )
Env env;
env.clear_all_white_nodes = delete_white_text_items;
env_tab.push_back(env);
}
void PatternParser::IncreaseEnvTab()
{
if( env_tab.empty() )
{
out += ' ';
out += arg;
InitializeEnvTab();
}
else
{
env_tab.push_back(env_tab.back());
}
out += commentary_stop;
}
@ -195,10 +171,13 @@ void PatternParser::ParseFile(const std::string & file_name, Pattern & pattern)
void PatternParser::ParseFile(const char * file_name, Pattern & pattern)
{
pat = &pattern;
pat->Clear();
pt::utf8_to_wide(file_name, pat->item_root.file_name);
include_level = 0;
InitializeEnvTab();
CreateTreeReadIncludeSkipAllowFlag(pat->item_root);
env_tab.clear();
}
@ -215,9 +194,13 @@ void PatternParser::ParseFile(const std::wstring & file_name, Pattern & pattern)
void PatternParser::ParseFile(const wchar_t * file_name, Pattern & pattern)
{
pat = &pattern;
pat->Clear();
pat->item_root.file_name = file_name;
include_level = 0;
InitializeEnvTab();
CreateTreeReadIncludeSkipAllowFlag(pat->item_root);
env_tab.clear();
}
@ -242,11 +225,13 @@ void PatternParser::ParseString(const std::string & str, Pattern & pattern)
void PatternParser::ParseString(const wchar_t * str, Pattern & pattern)
{
pat = &pattern;
pat->Clear();
itext = str;
include_level = 0;
InitializeEnvTab();
pat->item_root.Clear();
CreateTreeContainer(pat->item_root);
env_tab.clear();
}
@ -350,15 +335,25 @@ void PatternParser::ReadFile(const wchar_t * name, std::wstring & result)
{
if( !IsFileCorrect(name) )
{
CreateMsg(result, L"incorrect file name: ", name);
if( log )
{
(*log) << pt::Log::log2 << "Ezc: incorrect file name: " << name << pt::Log::logend;
}
}
else
{
result.clear();
if( !ReadFileFromDir(directory, name, result) )
{
if( !ReadFileFromDir(directory2, name, result) )
CreateMsg(result, L"can't open: ", name);
{
if( log )
{
(*log) << pt::Log::log2 << "Ezc: can't open file: " << name << pt::Log::logend;
}
}
}
}
}
@ -425,13 +420,7 @@ return *(itext++);
bool PatternParser::IsWhite(wchar_t c)
{
// 13 (\r) is from a dos file at the end of a line (\r\n)
// 160 is a non-breaking space
if( c==' ' || c=='\t' || c==13 || c==160 || c==10 )
return true;
return false;
return pt::is_white(c, true, true);
}
@ -463,7 +452,7 @@ size_t count = 1;
void PatternParser::CheckWhiteAndDelete(std::wstring & s)
{
size_t i;
if( s.empty() )
return;
@ -486,7 +475,7 @@ bool PatternParser::IsNameChar(wchar_t c)
return ((c>='a' && c<='z') ||
(c>='A' && c<='Z') ||
(c>='0' && c<='9') ||
c=='_' || c=='-' || c=='.' || c=='#' || c=='?');
c=='_' || c=='-' || c=='#' || c=='?');
}
@ -622,7 +611,28 @@ return res;
}
void PatternParser::ReadFunctionFields(Item::Function & function)
{
std::wstring field;
bool read_next_field = true;
while( *itext == '.' && read_next_field )
{
itext += 1;
read_next_field = ReadName(field);
if( read_next_field )
{
function.fields.emplace_back(field);
}
}
if( *itext == ':' )
{
itext += 1;
ReadName(function.postfix); // we allow the postfix to be empty
}
}
bool PatternParser::ReadFunction(Item::Function & function, bool with_params)
@ -654,14 +664,12 @@ bool PatternParser::ReadFunction(Item::Function & function, bool with_params)
if( res )
{
if( *itext == ':' )
{
itext += 1;
ReadName(function.postfix); // we allow the postfix to be empty
}
ReadFunctionFields(function);
if( with_params )
{
res = ReadParams(function);
}
}
}
@ -737,6 +745,35 @@ void PatternParser::ReadDirectiveIf(Item & item)
}
void PatternParser::ReadDirectiveIfDef(Item & item)
{
item.type = Item::item_if_def;
if( ReadFunction(item) )
{
if( !item.function.is_function || item.function.parameters.size() > 0 )
{
item.type = Item::item_err;
item.function.Clear();
}
}
}
void PatternParser::ReadDirectiveIfNotDef(Item & item)
{
item.type = Item::item_if_not_def;
if( ReadFunction(item) )
{
if( !item.function.is_function || item.function.parameters.size() > 0 )
{
item.type = Item::item_err;
item.function.Clear();
}
}
}
void PatternParser::ReadDirectiveEnd(Item & item)
{
@ -870,6 +907,9 @@ void PatternParser::ReadDirectiveFilter(Item & item)
}
void PatternParser::ReadDirectiveEzc(Item & item)
{
item.type = Item::item_ezc;
@ -920,7 +960,53 @@ void PatternParser::ReadDirectiveReturn(Item & item)
}
/*
* returns true if an Env struct has been added to env_tab
*/
bool PatternParser::CheckEnv(Item & item)
{
if( item.function.name == L"clear_all_white_nodes" )
{
IncreaseEnvTab();
env_tab.back().clear_all_white_nodes = CheckEnvIsYesParameter(item);
return true;
}
if( item.function.name == L"trim_text_nodes" )
{
IncreaseEnvTab();
env_tab.back().trim_text_nodes = CheckEnvIsYesParameter(item);
return true;
}
return false;
}
/*
*
* if no parameters are present then we assume the "yes" is by default
*
*/
bool PatternParser::CheckEnvIsYesParameter(Item & item)
{
if( item.function.parameters.size() > 0 && !item.function.parameters[0]->is_function )
{
std::wstring & name = item.function.parameters[0]->name;
if( name == L"yes" || name == L"true" )
{
return true;
}
else
if( name == L"no" || name == L"false" )
{
return false;
}
}
return true;
}
void PatternParser::CreateTreeReadItemDirective(Item & item)
@ -934,6 +1020,8 @@ std::wstring name;
ReadName(name);
if ( name == L"if" ) ReadDirectiveIf(item);
else if( name == L"if-def" ) ReadDirectiveIfDef(item);
else if( name == L"if-not-def" )ReadDirectiveIfNotDef(item);
else if( name == L"end" ) ReadDirectiveEnd(item);
else if( name == L"else" ) ReadDirectiveElse(item);
else if( name == L"for" ) ReadDirectiveFor(item);
@ -966,8 +1054,20 @@ int c;
while( (c = ReadCharInText()) != -1 )
item.text += static_cast<wchar_t>(c);
if( delete_white_text_items )
CheckWhiteAndDelete(item.text);
if( !env_tab.empty() )
{
Env & env = env_tab.back();
if( env.clear_all_white_nodes )
{
CheckWhiteAndDelete(item.text);
}
if( env.trim_text_nodes )
{
pt::trim_white(item.text, true, true);
}
}
item.type = Item::item_text;
}
@ -1142,7 +1242,7 @@ void PatternParser::CreateTreeReadIncludeSkipAllowFlag(Item & item)
{
if( log )
{
(*log) << pt::Log::log1 << "Ezc: \"include\" directive has reached the maximum level" << pt::Log::logend;
(*log) << pt::Log::log2 << "Ezc: \"include\" directive has reached the maximum level" << pt::Log::logend;
}
return;
@ -1218,7 +1318,7 @@ void PatternParser::CreateTreeReadBlock(Item & item)
void PatternParser::CreateTreeReadFor(Item & item)
void PatternParser::CreateTreeReadOneChild(Item & item)
{
Item * pitem = item.AddItem();
@ -1247,22 +1347,29 @@ bool PatternParser::CreateTree(Item & item)
}
while( item.type == Item::item_comment || item.type == Item::item_block );
bool reduce_env_tab = false;
if(item.type == Item::item_ezc)
reduce_env_tab = CheckEnv(item);
// such container can be read in program mode
if( item.type == Item::item_container )
CreateTreeContainer(item);
if( item.type == Item::item_if )
CreateTreeReadIf(item);
if( item.type == Item::item_if || item.type == Item::item_if_def || item.type == Item::item_if_not_def )
CreateTreeReadIf(item); // reads one child or two if [else] statement is present
// CHECK ME is it correct to check item_filter and item_ezc here and call CreateTreeReadFor?
if( item.type == Item::item_for ||
item.type == Item::item_filter ||
item.type == Item::item_ezc )
CreateTreeReadFor(item);
CreateTreeReadOneChild(item);
if( item.type == Item::item_include )
CreateTreeReadInclude(item);
if( reduce_env_tab && !env_tab.empty() )
env_tab.resize(env_tab.size() - 1);
return true;
}

View File

@ -79,20 +79,27 @@ public:
void AllowInclude(bool allow);
void DeleteWhiteTextItems(bool del);
void SetIncludeMax(int include_max);
void SetBlocks(Blocks & blocks);
void SetCommentary(const char * com_start, const char * com_stop);
void SetCommentary(const std::string & com_start, const std::string & com_stop);
void SetCommentary(const wchar_t * com_start, const wchar_t * com_stop);
void SetCommentary(const std::wstring & com_start, const std::wstring & com_stop);
void SetProgramMode(bool program_mode);
void SetLogger(pt::Log * log);
private:
struct Env
{
bool clear_all_white_nodes;
bool trim_text_nodes;
Env()
{
clear_all_white_nodes = false;
trim_text_nodes = false;
}
};
std::vector<Env> env_tab;
// the output object
Pattern * pat;
@ -117,8 +124,6 @@ private:
std::wstring directory, directory2;
std::wstring commentary_start, commentary_stop;
int include_level, include_level_max;
@ -140,7 +145,8 @@ private:
pt::Log * log;
void CreateMsg(std::wstring & out, const wchar_t * type, const wchar_t * arg = 0);
void InitializeEnvTab();
void IncreaseEnvTab();
void ReadFile(const std::wstring & name, std::wstring & result);
void ReadFile(const wchar_t * name, std::wstring & result);
@ -165,10 +171,13 @@ private:
bool ReadString(std::wstring & str);
bool ReadParamString(Item::Function & function);
bool ReadParams(Item::Function & function);
void ReadFunctionFields(Item::Function & function);
bool ReadFunction(Item::Function & function, bool with_params);
bool ReadFunction(Item & item);
void ReadDirectiveIf(Item & item);
void ReadDirectiveIfDef(Item & item);
void ReadDirectiveIfNotDef(Item & item);
void ReadDirectiveEnd(Item & item);
void ReadDirectiveElse(Item & item);
void ReadDirectiveFor(Item & item);
@ -185,6 +194,9 @@ private:
void ReadDirectiveReturn(Item & item);
void ReadNormalStatement(Item & item);
bool CheckEnv(Item & item);
bool CheckEnvIsYesParameter(Item & item);
void CreateTreeReadDirectiveExpression(Item & item, bool is_statement);
bool CreateTreeCheckProgramDirective(Item & item);
bool CreateTreeReadExpression(Item & item);
@ -195,7 +207,7 @@ private:
bool CreateTreeReadItem(Item & item);
void CreateTreeReadIf(Item & item);
void CreateTreeReadBlock(Item & item);
void CreateTreeReadFor(Item & item);
void CreateTreeReadOneChild(Item & item);
bool CreateTree(Item & item);
void CreateTreeContainer(Item & item);
void CreateTreeReadInclude(Item & item);