added: [return ...] statement for a block

changed: a user definied function now is able to get a string and a boolean value (parameters)
changed: we do not longer support aliases for variables
         a variable is only a string and a boolean value now



git-svn-id: svn://ttmath.org/publicrep/ezc/trunk@981 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2014-10-28 17:46:24 +00:00
parent 6bd8889456
commit 0a7bd3159a
5 changed files with 153 additions and 135 deletions

View File

@@ -578,6 +578,7 @@ bool PatternParser::ReadFunction(Item::Function & function)
if( !ReadName(function.name) )
return false;
// !! IMPROVE ME add skiping some white characters (at the beginning and at the end)
if( IsPositiveNumber(function.name) )
function.arg = wcstol(function.name.c_str(), 0, 10);
@@ -787,11 +788,11 @@ void PatternParser::ReadDirectiveDef(Item & item)
}
else
if( item.functions.size() == 2 &&
item.functions[0].parameters.empty() && item.functions[1].parameters.empty() )
item.functions[0].parameters.empty() )
{
// it is an alias:
// it is:
// [def name function]
// (name is an alias to a function, to a block or to an other variable)
// or [def name function "funpar1" "funpar2"] etc.
item.type = Item::item_def;
}
@@ -814,6 +815,7 @@ void PatternParser::ReadDirectiveEzc(Item & item)
ReadFunctions(item);
}
void PatternParser::ReadDirectiveBlock(Item & item)
{
item.type = Item::item_block;
@@ -825,6 +827,16 @@ void PatternParser::ReadDirectiveBlock(Item & item)
}
void PatternParser::ReadDirectiveReturn(Item & item)
{
item.type = Item::item_return;
ReadFunctions(item);
// max one function
if( item.functions.size() > 1 )
item.type = Item::item_err;
}
// user defined directive
void PatternParser::ReadDirectiveNormal(const std::wstring & name, Item & item)
@@ -868,6 +880,7 @@ std::wstring name;
else if( name == L"filter" ) ReadDirectiveFilter(item);
else if( name == L"ezc" ) ReadDirectiveEzc(item);
else if( name == L"block" ) ReadDirectiveBlock(item);
else if( name == L"return" ) ReadDirectiveReturn(item);
else if( name == L"#" ) ReadDirectiveComment(item);
else
ReadDirectiveNormal(name, item);
@@ -1042,8 +1055,6 @@ void PatternParser::CreateTree(Item & item)
if( pitem->type == Item::item_include )
CreateTreeReadInclude(*pitem);
// item_def is ignored here
}
}