Ignore:
Timestamp:
04/21/04 15:38:08 (21 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mdata
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mdata/MDataChain.cc

    r3666 r3788  
    4545//   "MCameraLV.fPowerSupplyA.fVoltagePos5V"
    4646//
    47 // You can also use brackets:
     47// You can also use parantheses:
    4848//   "HillasDource.fDist / (MHillas.fLength + MHillas.fWidth)"
    4949//
     
    5757// While a^b returns a to the power of b
    5858//
    59 // Warning: There is no priority rule build in. So better use brackets
     59// Warning: There is no priority rule build in. So better use parantheses
    6060//   to get correct results. The rule is parsed/evaluated from the left
    6161//   to the right, which means:
     
    158158//  - The possibility to use other objects inheriting from MData
    159159//    is missing.
    160 //  - By automatic pre-adding brackets to the rule it would be possible
     160//  - By automatic pre-adding parantheses to the rule it would be possible
    161161//    to implement priorities for operators.
    162162//
     
    365365}
    366366
     367void MDataChain::SimplifyString(TString &txt) const
     368{
     369    while (txt.First("--")>=0 || txt.First("++")>=0 ||
     370           txt.First("+-")>=0 || txt.First("-+")>=0)
     371    {
     372        txt.ReplaceAll("--", "+");
     373        txt.ReplaceAll("++", "+");
     374        txt.ReplaceAll("-+", "-");
     375        txt.ReplaceAll("+-", "-");
     376    }
     377}
     378
    367379// --------------------------------------------------------------------------
    368380//
     
    371383MData *MDataChain::ParseString(TString txt, Int_t level)
    372384{
     385    if (level==0)
     386        SimplifyString(txt);
     387
    373388    MData *member0=NULL;
    374389
     
    387402            {
    388403                //
    389                 // Search for the corresponding bracket
    390                 //
    391                 Int_t first=GetBracket(txt, '(', ')');
    392 
     404                // Search for the corresponding parantheses
     405                //
     406                const Int_t first=GetBracket(txt, '(', ')');
    393407                if (first==txt.Length())
    394408                {
     
    400414
    401415                //
    402                 // Make a copy of the 'interieur' and delete the substringä
     416                // Make a copy of the 'interieur' and delete the substring
    403417                // including the brackets
    404418                //
     
    462476            if (txt[0]!='-' && txt[0]!='+')
    463477            {
    464                 *fLog << err << dbginf << "Syntax Error: First argument of symbol '";
    465                 *fLog << txt[0] << "' missing." << endl;
     478                *fLog << err << dbginf << "Syntax Error: First argument of '";
     479                *fLog << txt[0] << "' opartor missing." << endl;
    466480                if (member0)
    467481                    delete member0;
  • trunk/MagicSoft/Mars/mdata/MDataChain.h

    r3666 r3788  
    4444    Int_t GetBracket(TString txt, char open, char close);
    4545
     46    void   SimplifyString(TString &txt) const;
    4647    MData *ParseString(TString txt, Int_t level);
    4748    MData *ParseDataMember(TString txt);
Note: See TracChangeset for help on using the changeset viewer.