Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
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)
|
||||
{
|
||||
ReadDirectiveIfany(item);
|
||||
@@ -438,6 +448,9 @@ void Pattern::CreateTreeReadItemDirective(Item & item)
|
||||
if( directive == "if-any" )
|
||||
ReadDirectiveIfany(item);
|
||||
else
|
||||
if( directive == "if-no" )
|
||||
ReadDirectiveIfno(item);
|
||||
else
|
||||
if( directive == "if-one" )
|
||||
ReadDirectiveIfone(item);
|
||||
else
|
||||
@@ -567,6 +580,7 @@ void Pattern::CreateTree(Item & item)
|
||||
return;
|
||||
|
||||
if( pitem->type == Item::item_ifany ||
|
||||
pitem->type == Item::item_ifno ||
|
||||
pitem->type == Item::item_ifone ||
|
||||
pitem->type == Item::item_ifindex ||
|
||||
pitem->type == Item::item_is )
|
||||
@@ -939,6 +953,7 @@ void Generator::MakeTextIfany(Pattern::Item & item)
|
||||
for( ; d != item.directives.end() ; ++d )
|
||||
{
|
||||
if( !Call(*d, info1) )
|
||||
// maybe it should only be treated as a false? (when there is no such a function/variable)
|
||||
return;
|
||||
|
||||
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)
|
||||
{
|
||||
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 )
|
||||
{
|
||||
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 );
|
||||
@@ -1163,6 +1202,9 @@ void Generator::MakeText(Pattern::Item & item)
|
||||
case Pattern::Item::item_ifany:
|
||||
MakeTextIfany(item);
|
||||
break;
|
||||
case Pattern::Item::item_ifno:
|
||||
MakeTextIfno(item);
|
||||
break;
|
||||
case Pattern::Item::item_ifone:
|
||||
MakeTextIfone(item);
|
||||
break;
|
||||
|
@@ -36,7 +36,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* version 0.9.1
|
||||
* version 0.9.2
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -78,7 +78,7 @@ public:
|
||||
// change the name to 'Type'
|
||||
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_include, item_is, item_ifone, item_comment, item_def
|
||||
};
|
||||
@@ -125,6 +125,7 @@ private:
|
||||
void CreateTreeReadItemDirectiveCheckEnding(Item & item);
|
||||
|
||||
void ReadDirectiveIfany(Item & item);
|
||||
void ReadDirectiveIfno(Item & item);
|
||||
void ReadDirectiveIfone(Item & item);
|
||||
void ReadDirectiveIs(Item & item);
|
||||
void ReadDirectiveIfindex(Item & item);
|
||||
@@ -243,6 +244,7 @@ private:
|
||||
void MakeTextIf_go(Pattern::Item & item, bool result);
|
||||
bool MakeTextIfindexnumber(Pattern::Item & item, Functions::Function * function, bool & result);
|
||||
void MakeTextIfany(Pattern::Item & item);
|
||||
void MakeTextIfno(Pattern::Item & item);
|
||||
void MakeTextIfone(Pattern::Item & item);
|
||||
void MakeTextIfindex(Pattern::Item & item);
|
||||
void MakeTextFor(Pattern::Item & item);
|
||||
|
Reference in New Issue
Block a user