Downloads Documentation Community Contribute Demo






Show Sidebar
Login | Register

Changeset 5304

Show
Ignore:
Timestamp:
08/18/08 14:12:14 (3 months ago)
Author:
vanand
Message:

openmrs-logic-api-refactoring: changes for new logicCriteria structure

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • openmrs/branches/logic-api-refactoring/src/api/org/openmrs/logic/queryparser/LogicQueryParser.g

    r5166 r5304  
    503503//(of_read_func_op) | (from_of_func_op (INTLIT )?) expr (temporal_comp_op iso_date_time) ?      SEMI;  
    504504  
    505 query_AST [LogicCriteria lc] returns [LogicCriteria lc_return = null] 
     505query_AST returns [LogicCriteria lc_return = null] 
    506506{String a = "", b=""; 
    507507Operator transform = null, comp_op = null, temporal_op = null; 
     
    509509: 
    510510( 
    511         (transform = of_from_AST[lc])?  
     511        (transform = of_from_AST)?  
    512512        ( 
    513513                #(ift:ID  
    514514                                      { a = ift.getText(); //System.err.println("text = " + a); 
    515                                         lc.setRightOperand(ift.getText()); 
    516                                          
     515                                                                         
    517516                                      } 
    518517                                     
     
    521520                #(ifst:STRING_LITERAL  
    522521                                      { a = ifst.getText(); //System.err.println("text = " + a); 
    523                                         lc.setRightOperand(ifst.getText()); 
    524522                                         
    525523                                      } 
     
    529527                #(val:INTLIT 
    530528                                      { a = val.getText(); //System.err.println("text = " + a); 
    531                                         lc.setRightOperand(val.getText()); 
     529                                        // This is an error on LHS of an expr 
    532530                                      } 
    533531                 
     
    536534        ( 
    537535                (              
    538                         comp_op = simple_comp_op[lc,a]   
     536                        comp_op = simple_comp_op   
    539537                        ( 
    540538                                #(idt:ID  
    541539                                              { b += idt.getText(); //System.err.println("text = " + b); 
    542                                                 LogicCriteria ac = new LogicCriteria(comp_op, b); 
    543                                                 lc = lc.appendCriteria(Operator.AND, ac); 
    544                                                     //System.out.println(lc.toString());  
    545540                                              } 
    546541                                             
     
    549544                                #(idstr:STRING_LITERAL  
    550545                                                  { b += idstr.getText(); //System.err.println("text = " + b); 
    551                                                         LogicCriteria ac = new LogicCriteria(comp_op, b); 
    552                                                 lc = lc.appendCriteria(Operator.AND, ac); 
    553                                                     //System.out.println(lc.toString()); 
    554546                                                  } 
    555547                                                     
     
    558550                                #(valstr:INTLIT 
    559551                                                  { b += valstr.getText(); //System.err.println("text = " + b); 
    560                                                         LogicCriteria ac = new LogicCriteria(comp_op, b); 
    561                                                 lc = lc.appendCriteria(Operator.AND, ac); 
    562                                                     //System.out.println(lc.toString()); 
    563552                                                  } 
    564553                                 
    565554                                )       
    566555                        ) 
     556                        {LogicCriteria lc = new LogicCriteria(null,a); 
     557                         lc.appendExpression(comp_op, b); 
     558                         lc_return = lc.applyTransform(transform); 
     559                        }  
    567560                ) ? 
    568561                | 
    569562                ( 
    570                         temporal_op = temporal_comp_op[lc,a]   
     563                        temporal_op = temporal_comp_op   
    571564                        ( 
    572565                                {GregorianCalendar gc = new GregorianCalendar();} b = dateAST [gc]  
    573                                                   {  
    574                                                         LogicCriteria ac = new LogicCriteria(temporal_op, gc); 
    575                                                 lc = lc.appendCriteria(Operator.AND, ac); 
    576                                                     //System.out.println(gc.toString()); 
    577                                                     //{System.err.println("date = " + b);} 
    578                                                   } 
    579                                                   
    580                                  
    581                                      
     566                                                { 
     567                                                        LogicCriteria lc = new LogicCriteria(null,a); 
     568                                                        lc.appendExpression(temporal_op, gc); 
     569                                                        lc_return = lc.applyTransform(transform); 
     570                                                }                                
     571                                                     
    582572                        ) 
     573                         
    583574                )? 
    584575        )  
    585576        { 
    586                 lc_return = lc.applyTransform(transform); 
    587                 //System.out.println(lc_return.toString()); 
     577                if(lc_return == null)  // just a terminal symbol like CD4 COUNT 
     578                { 
     579                        lc_return = new LogicCriteria(null,a); 
     580                } 
    588581                return lc_return; 
    589582        }                       
     
    618611        ; 
    619612 
    620 simple_comp_op[LogicCriteria lc, String operand] returns [Operator s = null] 
    621 {String a,b;} 
     613simple_comp_op returns [Operator s = null] 
     614{String a = "", b="";} 
    622615: 
    623616( 
     
    660653; 
    661654 
    662 temporal_comp_op[LogicCriteria lc, String operand] returns [Operator s = null] 
    663 {String a,b;} 
     655temporal_comp_op returns [Operator s = null] 
     656{String a = "", b="";} 
    664657: 
    665658( 
     
    680673 
    681674 
    682 of_from_AST [LogicCriteria lc] returns [Operator s = null] 
     675of_from_AST returns [Operator s = null] 
    683676{} 
    684677: