[ Index ] |
PHP Cross Reference of vtigercrm-6.1.0 |
[Summary view] [Print] [Text view]
1 <?php 2 /*+******************************************************************************* 3 * The contents of this file are subject to the vtiger CRM Public License Version 1.0 4 * ("License"); You may not use this file except in compliance with the License 5 * The Original Code is: vtiger CRM Open Source 6 * The Initial Developer of the Original Code is vtiger. 7 * Portions created by vtiger are Copyright (C) vtiger. 8 * All Rights Reserved. 9 ******************************************************************************/ 10 class VTExpressionToken{ 11 function __construct($label){ 12 $this->label = $label; 13 } 14 } 15 16 function _vt_processtoken_id($token){ 17 return $token; 18 } 19 20 function _vt_processtoken_symbol($token){ 21 return new VTEXpressionSymbol($token); 22 } 23 24 class VTExpressionTokenizer{ 25 function __construct($expr){ 26 $tokenTypes = array( 27 "SPACE" => array('\s+', '_vt_processtoken_id'), 28 "SYMBOL" => array('[a-zA-Z][\w]*', '_vt_processtoken_symbol'), 29 "ESCAPED_SYMBOL" => array('?:`([^`]+)`', '_vt_processtoken_symbol'), 30 //"STRING" => array('?:(?:"((?:\\\\"|[^"])+)"|'."'((?:\\\\'|[^'])+)')", 'stripcslashes'), 31 //"STRING" => array('?:"((?:\\\\"|[^"])+)"', 'stripcslashes'), 32 "STRING" => array("?:'((?:\\\\'|[^'])+)'", 'stripcslashes'), 33 "FLOAT" => array('\d+[.]\d+', 'floatval'), 34 "INTEGER" => array('\d+', 'intval'), 35 'OPERATOR' => array('[+]|[-]|[*]|>=|<=|[<]|[>]|==|\/', '_vt_processtoken_symbol'), 36 // NOTE: Any new Operator added should be updated in VTParser.inc::$precedence and operation at VTExpressionEvaluater 37 'OPEN_BRACKET' => array('[(]', '_vt_processtoken_symbol'), 38 'CLOSE_BRACKET' => array('[)]', '_vt_processtoken_symbol'), 39 'COMMA' => array('[,]', '_vt_processtoken_symbol') 40 ); 41 $tokenReArr = array(); 42 $tokenNames = array(); 43 $this->tokenTypes = $tokenTypes; 44 45 foreach($tokenTypes as $tokenName => $code){ 46 list($re, $processtoken) = $code; 47 $tokenReArr[] = '('.$re.')'; 48 $tokenNames[] = $tokenName; 49 } 50 $this->tokenNames = $tokenNames; 51 $tokenRe = '/'.implode('|', $tokenReArr).'/'; 52 $this->EOF = new VTExpressionToken("EOF"); 53 54 $matches = array(); 55 preg_match_all($tokenRe, $expr, $matches, PREG_SET_ORDER); 56 $this->matches = $matches; 57 $this->idx = 0; 58 } 59 function nextToken(){ 60 $matches = $this->matches; 61 $idx = $this->idx; 62 if($idx == sizeof($matches)){ 63 return $this->EOF; 64 }else{ 65 $match = $matches[$idx]; 66 $this->idx = $idx + 1; 67 $i=1; 68 while($match[$i]==null){ 69 $i+=1; 70 } 71 $tokenName = $this->tokenNames[$i-1]; 72 $token = new VTExpressionToken($tokenName); 73 $token->value = $this->tokenTypes[$tokenName][1]($match[$i]); 74 return $token; 75 } 76 } 77 } 78 79 class VTExpressionSpaceFilter{ 80 function __construct($tokens){ 81 $this->tokens = $tokens; 82 } 83 84 function nextToken(){ 85 do{ 86 $token = $this->tokens->nextToken(); 87 }while($token->label == "SPACE"); 88 return $token; 89 } 90 } 91 92 93 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:08:37 2014 | Cross-referenced by PHPXref 0.7.1 |