Browse Source

added: directive [is-no ...] negative to [is ...]

git-svn-id: svn://ttmath.org/publicrep/ezc/trunk@290 e52654a7-88a9-db11-a3e9-0013d4bc506e
master
Tomasz Sowa 12 years ago
parent
commit
31156d33f3
  1. 26
      src/ezc.cpp
  2. 5
      src/ezc.h

26
src/ezc.cpp

@ -454,6 +454,15 @@ void Pattern::ReadDirectiveIs(Item & item)
}
void Pattern::ReadDirectiveIsno(Item & item)
{
ReadDirectiveIs(item);
if( item.type == Item::item_is )
item.type = Item::item_isno;
}
void Pattern::ReadDirectiveIfindex(Item & item)
{
item.type = Item::item_ifindex;
@ -547,6 +556,9 @@ void Pattern::CreateTreeReadItemDirective(Item & item)
if( directive.name == "is" )
ReadDirectiveIs(item);
else
if( directive.name == "is-no" )
ReadDirectiveIsno(item);
else
if( directive.name == "if-index" )
ReadDirectiveIfindex(item);
else
@ -676,7 +688,8 @@ void Pattern::CreateTree(Item & item)
pitem->type == Item::item_ifno ||
pitem->type == Item::item_ifone ||
pitem->type == Item::item_ifindex ||
pitem->type == Item::item_is )
pitem->type == Item::item_is ||
pitem->type == Item::item_isno )
CreateTreeReadIf(*pitem);
if( pitem->type == Item::item_for )
@ -1146,7 +1159,9 @@ return false;
}
void Generator::MakeTextIs(Pattern::Item & item)
// if 'isno' is true that means we're generating tag [is-no ...]
// default: false
void Generator::MakeTextIs(Pattern::Item & item, bool isno)
{
if( item.directives.size() != 2 )
return;
@ -1177,11 +1192,15 @@ void Generator::MakeTextIs(Pattern::Item & item)
// both directive are not text
MakeTextIsFunFun(item.directives[0].name, item.directives[1].name, result);
}
if( isno )
result = !result;
MakeTextIf_go(item, result);
}
bool Generator::MakeTextIfindexnumber(Pattern::Item & item, Functions::Function * function, bool & result)
{
if( item.directives.size() != 2 )
@ -1362,6 +1381,9 @@ void Generator::MakeText(Pattern::Item & item)
case Pattern::Item::item_is:
MakeTextIs(item);
break;
case Pattern::Item::item_isno:
MakeTextIs(item, true);
break;
case Pattern::Item::item_for:
MakeTextFor(item);
break;

5
src/ezc.h

@ -80,7 +80,7 @@ public:
{
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
item_include, item_is, item_isno, item_ifone, item_comment, item_def
};
struct Directive
@ -146,6 +146,7 @@ private:
void ReadDirectiveIfno(Item & item);
void ReadDirectiveIfone(Item & item);
void ReadDirectiveIs(Item & item);
void ReadDirectiveIsno(Item & item);
void ReadDirectiveIfindex(Item & item);
void ReadDirectiveFor(Item & item);
void ReadDirectiveComment(Item & item);
@ -271,7 +272,7 @@ private:
void MakeTextNormal(Pattern::Item & item);
bool MakeTextIsFunText(const std::string & fun_name, const std::string & text, bool & res);
bool MakeTextIsFunFun(const std::string & fun_name1, const std::string & fun_name2, bool & res);
void MakeTextIs(Pattern::Item & item);
void MakeTextIs(Pattern::Item & item, bool isno = false);
void MakeTextDefine(Pattern::Item & item);
void MakeText(Pattern::Item & item);

Loading…
Cancel
Save