added: directive [if-no fun1 fun2 ...]
if fun1 fun2 ... return false then the content is evaluated changed: [if-one fun1 fun2 ...] when a function (from left to right) returns true then the content is evaluated (previous all functions were called) git-svn-id: svn://ttmath.org/publicrep/ezc/trunk@91 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
parent
0760313ec3
commit
0b88257e08
42
src/ezc.cpp
42
src/ezc.cpp
|
@ -324,6 +324,16 @@ void Pattern::ReadDirectiveIfany(Item & item)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void Pattern::ReadDirectiveIfno(Item & item)
|
||||||
|
{
|
||||||
|
ReadDirectiveIfany(item);
|
||||||
|
|
||||||
|
if( item.type == Item::item_ifany )
|
||||||
|
item.type = Item::item_ifno;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Pattern::ReadDirectiveIfone(Item & item)
|
void Pattern::ReadDirectiveIfone(Item & item)
|
||||||
{
|
{
|
||||||
ReadDirectiveIfany(item);
|
ReadDirectiveIfany(item);
|
||||||
|
@ -438,6 +448,9 @@ void Pattern::CreateTreeReadItemDirective(Item & item)
|
||||||
if( directive == "if-any" )
|
if( directive == "if-any" )
|
||||||
ReadDirectiveIfany(item);
|
ReadDirectiveIfany(item);
|
||||||
else
|
else
|
||||||
|
if( directive == "if-no" )
|
||||||
|
ReadDirectiveIfno(item);
|
||||||
|
else
|
||||||
if( directive == "if-one" )
|
if( directive == "if-one" )
|
||||||
ReadDirectiveIfone(item);
|
ReadDirectiveIfone(item);
|
||||||
else
|
else
|
||||||
|
@ -567,6 +580,7 @@ void Pattern::CreateTree(Item & item)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if( pitem->type == Item::item_ifany ||
|
if( pitem->type == Item::item_ifany ||
|
||||||
|
pitem->type == Item::item_ifno ||
|
||||||
pitem->type == Item::item_ifone ||
|
pitem->type == Item::item_ifone ||
|
||||||
pitem->type == Item::item_ifindex ||
|
pitem->type == Item::item_ifindex ||
|
||||||
pitem->type == Item::item_is )
|
pitem->type == Item::item_is )
|
||||||
|
@ -939,6 +953,7 @@ void Generator::MakeTextIfany(Pattern::Item & item)
|
||||||
for( ; d != item.directives.end() ; ++d )
|
for( ; d != item.directives.end() ; ++d )
|
||||||
{
|
{
|
||||||
if( !Call(*d, info1) )
|
if( !Call(*d, info1) )
|
||||||
|
// maybe it should only be treated as a false? (when there is no such a function/variable)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if( info1.IsTrue() )
|
if( info1.IsTrue() )
|
||||||
|
@ -949,6 +964,26 @@ void Generator::MakeTextIfany(Pattern::Item & item)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Generator::MakeTextIfno(Pattern::Item & item)
|
||||||
|
{
|
||||||
|
std::vector<std::string>::iterator d = item.directives.begin();
|
||||||
|
unsigned how_many_true = 0;
|
||||||
|
|
||||||
|
for( ; d != item.directives.end() ; ++d )
|
||||||
|
{
|
||||||
|
if( Call(*d, info1) && info1.IsTrue() )
|
||||||
|
{
|
||||||
|
// there is no sense to go through all functions
|
||||||
|
++how_many_true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MakeTextIf_go(item, how_many_true == 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Generator::MakeTextIfone(Pattern::Item & item)
|
void Generator::MakeTextIfone(Pattern::Item & item)
|
||||||
{
|
{
|
||||||
std::vector<std::string>::iterator d = item.directives.begin();
|
std::vector<std::string>::iterator d = item.directives.begin();
|
||||||
|
@ -957,7 +992,11 @@ void Generator::MakeTextIfone(Pattern::Item & item)
|
||||||
for( ; d != item.directives.end() ; ++d )
|
for( ; d != item.directives.end() ; ++d )
|
||||||
{
|
{
|
||||||
if( Call(*d, info1) && info1.IsTrue() )
|
if( Call(*d, info1) && info1.IsTrue() )
|
||||||
|
{
|
||||||
|
// there is no sense to go through all functions
|
||||||
++how_many_true;
|
++how_many_true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MakeTextIf_go(item, how_many_true > 0 );
|
MakeTextIf_go(item, how_many_true > 0 );
|
||||||
|
@ -1163,6 +1202,9 @@ void Generator::MakeText(Pattern::Item & item)
|
||||||
case Pattern::Item::item_ifany:
|
case Pattern::Item::item_ifany:
|
||||||
MakeTextIfany(item);
|
MakeTextIfany(item);
|
||||||
break;
|
break;
|
||||||
|
case Pattern::Item::item_ifno:
|
||||||
|
MakeTextIfno(item);
|
||||||
|
break;
|
||||||
case Pattern::Item::item_ifone:
|
case Pattern::Item::item_ifone:
|
||||||
MakeTextIfone(item);
|
MakeTextIfone(item);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* version 0.9.1
|
* version 0.9.2
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ public:
|
||||||
// change the name to 'Type'
|
// change the name to 'Type'
|
||||||
enum ItemType
|
enum ItemType
|
||||||
{
|
{
|
||||||
item_none, item_container, item_text, item_ifany, item_for,
|
item_none, item_container, item_text, item_ifany, item_ifno, item_for,
|
||||||
item_else, item_end, item_err, item_normal, item_ifindex,
|
item_else, item_end, item_err, item_normal, item_ifindex,
|
||||||
item_include, item_is, item_ifone, item_comment, item_def
|
item_include, item_is, item_ifone, item_comment, item_def
|
||||||
};
|
};
|
||||||
|
@ -125,6 +125,7 @@ private:
|
||||||
void CreateTreeReadItemDirectiveCheckEnding(Item & item);
|
void CreateTreeReadItemDirectiveCheckEnding(Item & item);
|
||||||
|
|
||||||
void ReadDirectiveIfany(Item & item);
|
void ReadDirectiveIfany(Item & item);
|
||||||
|
void ReadDirectiveIfno(Item & item);
|
||||||
void ReadDirectiveIfone(Item & item);
|
void ReadDirectiveIfone(Item & item);
|
||||||
void ReadDirectiveIs(Item & item);
|
void ReadDirectiveIs(Item & item);
|
||||||
void ReadDirectiveIfindex(Item & item);
|
void ReadDirectiveIfindex(Item & item);
|
||||||
|
@ -243,6 +244,7 @@ private:
|
||||||
void MakeTextIf_go(Pattern::Item & item, bool result);
|
void MakeTextIf_go(Pattern::Item & item, bool result);
|
||||||
bool MakeTextIfindexnumber(Pattern::Item & item, Functions::Function * function, bool & result);
|
bool MakeTextIfindexnumber(Pattern::Item & item, Functions::Function * function, bool & result);
|
||||||
void MakeTextIfany(Pattern::Item & item);
|
void MakeTextIfany(Pattern::Item & item);
|
||||||
|
void MakeTextIfno(Pattern::Item & item);
|
||||||
void MakeTextIfone(Pattern::Item & item);
|
void MakeTextIfone(Pattern::Item & item);
|
||||||
void MakeTextIfindex(Pattern::Item & item);
|
void MakeTextIfindex(Pattern::Item & item);
|
||||||
void MakeTextFor(Pattern::Item & item);
|
void MakeTextFor(Pattern::Item & item);
|
||||||
|
|
Loading…
Reference in New Issue