2011-08-24 50 views
1

操作添加我有表達波蘭表達式規則 「中」,並與邏輯

ratecode in ('EURV','EURA','EURB','EURO','CHUPin*+-da~') && (sourcecode ~in ('FMFC','FM') || block == 'yes') 

現在是RPN規則

/// 2. Repeat until we reach end of infix expression 
    ///  I. Get token (operand or operator); skip white spaces 
    ///  II. If token is: 
    ///   a. Left parenthesis: Push it into stack 
    ///   b. Right parenthesis: Keep popping from the stack and appending to 
    ///    RPN string until we reach the left parenthesis. 
    ///    If stack becomes empty and we didn't reach the left parenthesis 
    ///    then break out with error "Unbalanced parenthesis" 
    ///   c. Operator: If stack is empty or operator has a higher precedence than 
    ///    the top of the stack then push operator into stack. 
    ///    Else if operator has lower precedence then we keep popping and 
    ///    appending to RPN string, this is repeated until operator in stack 
    ///    has lower precedence than the current operator. 
    ///   d. An operand: we simply append it to RPN string. 
    ///  III. When the infix expression is finished, we start popping off the stack and 
    ///    appending to RPN string till stack becomes empty. 

我加入& &,||,〜,中,

現在,它應該如何改變RPN的規則?

***更新

這是我的運營商

Operator Priority 
"+"  0 
"-"  0 
"&&"  0 
"||"  0 

"/"  1 
"*"  1 
"=="  1 
"("  1 

"~"  3 
"in"  3 
")"  3 

回答

2

的規則沒有爲這些額外的運營商改變的表。您只需爲每個運算符分配正確的優先級。例如,&&的優先級通常低於大多數其他運營商,並且||的優先級低於&&