changed: a function can have a postfix now e.g. [my_function:my_postfix]

this will be mainly used in conjuction with [for ...] statements

[for my_function:xxx]
  [for my_function]
    [my_function_value]
    [my_function_valu:xxx] (references the first loop)
  [end]
[end]

added: to FunInfo<>: a reference to current item from a pattern (const Item & item)
       similary on the stack is added a pointer to an item
       by having this reference you can compare a function's name and its postfix
       added methods:
       Stack * FindLastFor(const std::wstring & name);
       Stack * FindLastFor(const std::wstring & name, const std::wstring & postfix);
       template<class FunUserObject> FunUserObject * FindUserObject(const std::wstring & function_name, Stack ** ezc_stack = 0);




git-svn-id: svn://ttmath.org/publicrep/ezc/trunk@1038 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2016-04-04 15:53:11 +00:00
parent 18696d412b
commit 363605bde5
6 changed files with 71 additions and 36 deletions

View File

@@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2007-2015, Tomasz Sowa
* Copyright (c) 2007-2016, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -499,7 +499,6 @@ return true;
bool PatternParser::ReadName(std::wstring & name)
{
name.clear();
SkipWhite();
while( IsNameChar(*itext) )
{
@@ -638,15 +637,26 @@ return res;
/*
returns true if it correctly reads all parameters
*/
bool PatternParser::ReadFunction(Item::Function & function, bool with_params)
bool PatternParser::ReadFunction(Item::Function & function, bool with_params, const std::wstring * function_name)
{
SkipWhite();
function.Clear();
function.is_function = true;
if( function_name )
{
function.name = *function_name;
}
else
if( !ReadName(function.name) )
return false;
if( *itext == ':' )
{
itext += 1;
ReadName(function.postfix); // we allow the postfix to be empty
}
CheckFunctionIsNumber(function);
if( with_params )
@@ -707,12 +717,7 @@ void PatternParser::ReadDirectiveNormal(const std::wstring & name, Item & item)
item.type = Item::item_function;
item.has_function = true;
item.function.Clear();
item.function.name = name;
item.function.is_function = true;
CheckFunctionIsNumber(item.function);
if( !ReadParams(item.function) )
if( !ReadFunction(item.function, true, &name) )
{
item.type = Item::item_err;
item.function.Clear();
@@ -840,6 +845,7 @@ void PatternParser::CreateTreeReadItemDirective(Item & item)
std::wstring name;
++itext;
SkipWhite();
ReadName(name);
if ( name == L"if" ) ReadDirectiveIf(item);