rsel-exprparser-basic

Parses RSel-specific expression text and rebuilds it in the UI.

As of 2019-05-03. See the latest version.

This script should not be not be installed directly. It is a library for other scripts to include with the meta directive // @require https://update.greatest.deepsurf.us/scripts/17641/694906/rsel-exprparser-basic.js

  1. // ==UserScript==
  2. // @name rsel-exprparser-basic
  3. // @namespace https://greatest.deepsurf.us/users/11629-TheLastTaterTot
  4. // @version 2019.05.03.03
  5. // @description Parses RSel-specific expression text and rebuilds it in the UI.
  6. // @author TheLastTaterTot
  7. // @include https://editor-beta.waze.com/*editor/*
  8. // @include https://www.waze.com/*editor/*
  9. // @exclude https://www.waze.com/*user/editor/*
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. // Main usage: RSelExprParser.updateExpression(<rsel expression text>)
  14.  
  15. var RSelExprParser = {
  16. version: '2019.05.03.03',
  17. new__EXPR_DEBUGINFO: function(m, exprWord, exprPhrase) {
  18. return {
  19. m: m,
  20. exprMatches: exprWord,
  21. exprMatchPhrases: exprPhrase,
  22. exprBuild: {},
  23. err: null ,
  24. errorMsg: null
  25. };
  26. },
  27. escapeRegExp(s) {
  28. return s.replace(/[.*+?{}()|[\]\\\/]/g, '\\$&'); // $& means the whole matched string
  29. },
  30. _getSelectionIndex: function(selector, selText) {
  31. for (var s = 0, sLength = selector.length; s < sLength; s++) {
  32. if (new RegExp(RSelExprParser.escapeRegExp(selText),'i').test(selector[s].text) && !selector[s].disabled) {
  33. return selector[s].value;
  34. }
  35. }
  36. },
  37. _getSelectOptions: function(selector) {
  38. for (var opts = [], s = 0, sLength = selector.length; s < sLength; s++) {
  39. if (!selector[s].disabled) {
  40. opts[s] = selector[s].text.toLowerCase();
  41. }
  42. }
  43. return opts;
  44. },
  45. _getNewExprBuild: function() {
  46. return {
  47. cond: null ,
  48. op: null ,
  49. op2: null ,
  50. val: null ,
  51. val2: null ,
  52. condmod: null ,
  53. errorCode: 0
  54.  
  55. }
  56. },
  57. getCurrentExprText: function(){
  58. return document.getElementById('outRSExpr').value;
  59. },
  60. /*Using RSel DOM elements rather than requesting dev to provide direct modifiction of RSel's expr object.
  61. This is so the RSel dev can feel free to significantly change his object storage structure if needed. */
  62. rselButtons: {
  63. lfParens: function() {
  64. try {
  65. document.getElementById('btnRSLBkt').click();
  66. } catch (err) {}
  67. },
  68. rtParens: function() {
  69. try {
  70. document.getElementById('btnRSRBkt').click();
  71. } catch (err) {}
  72. },
  73. and: function() {
  74. try {
  75. document.getElementById('btnRSAnd').click()
  76. } catch (err) {}
  77. },
  78. or: function() {
  79. try {
  80. document.getElementById('btnRSOr').click()
  81. } catch (err) {}
  82. },
  83. not: function() {
  84. try {
  85. document.getElementById('btnRSNot').click()
  86. } catch (err) {}
  87. },
  88. clear: function() {
  89. try {
  90. document.getElementById('btnRSClear').click()
  91. } catch (err) {}
  92. }
  93. },
  94. rselConditions: {
  95. country: {
  96. op: function(selText) {
  97. selText = '^' + selText + '$';
  98. document.getElementById('opRSCountry').value = RSelExprParser._getSelectionIndex(document.getElementById('opRSCountry').options, selText);
  99. },
  100. val: function(selText) {
  101. selText = '^' + selText + '$';
  102. document.getElementById('selRSCountry').value = RSelExprParser._getSelectionIndex(document.getElementById('selRSCountry').options, selText);
  103. },
  104. add: function() {
  105. document.getElementById('btnRSAddCountry').click();
  106. }
  107. },
  108. state: {
  109. op: function(selText) {
  110. selText = '^' + selText + '$';
  111. document.getElementById('opRSState').value = RSelExprParser._getSelectionIndex(document.getElementById('opRSState').options, selText);
  112. },
  113. val: function(val) {
  114. document.getElementById('inRSState').value = val;
  115. },
  116. add: function() {
  117. document.getElementById('btnRSAddState').click();
  118. }
  119. },
  120. city: {
  121. op: function(selText) {
  122. selText = '^' + selText + '$';
  123. document.getElementById('opRSCity').value = RSelExprParser._getSelectionIndex(document.getElementById('opRSCity').options, selText);
  124. },
  125. val: function(val) {
  126. document.getElementById('inRSCity').value = val;
  127. },
  128. condmod: function(val) {
  129. document.getElementById('selRSAltCity').value = val;
  130. },
  131. add: function() {
  132. document.getElementById('btnRSAddCity').click();
  133. }
  134. },
  135. street: {
  136. op: function(selText) {
  137. selText = '^' + selText + '$';
  138. document.getElementById('opRSStreet').value = RSelExprParser._getSelectionIndex(document.getElementById('opRSStreet').options, selText);
  139. },
  140. val: function(val) {
  141. document.getElementById('inRSStreet').value = val;
  142. },
  143. condmod: function(val) {
  144. document.getElementById('selRSAlttStreet').value = val;
  145. },
  146. add: function() {
  147. document.getElementById('btnRSAddStreet').click();
  148. }
  149. },
  150. unnamed: {
  151. op: function(checked) {
  152. document.getElementById('cbRSNoName').checked = checked;
  153. },
  154. //checked - has no name
  155. op2: function(checked) {
  156. document.getElementById('cbRSAltNoName').checked = checked;
  157. },
  158. //checked - alt name
  159. add: function() {
  160. document.getElementById('btnRSAddNoName').click();
  161. }
  162. },
  163. road: {
  164. op: function(selText) {
  165. selText = '^' + selText + '$';
  166. document.getElementById('opRSRoadType').value = RSelExprParser._getSelectionIndex(document.getElementById('opRSRoadType').options, selText);
  167. },
  168. val: function(selText) {
  169. selText = '^' + selText.replace("/", "\/") + '$';
  170. document.getElementById('selRSRoadType').value = RSelExprParser._getSelectionIndex(document.getElementById('selRSRoadType').options, selText);
  171. },
  172. add: function() {
  173. document.getElementById('btnRSAddRoadType').click();
  174. }
  175. },
  176. direction: {
  177. op: function(selText) {
  178. selText = '^' + selText + '$';
  179. document.getElementById('opRSDirection').value = RSelExprParser._getSelectionIndex(document.getElementById('opRSDirection').options, selText);
  180. },
  181. val: function(selText) {
  182. document.getElementById('selRSDirection').value = RSelExprParser._getSelectionIndex(document.getElementById('selRSDirection').options, selText);
  183. },
  184. add: function() {
  185. document.getElementById('btnRSAddDirection').click();
  186. }
  187. },
  188. elevation: {
  189. op: function(selText) {
  190. selText = '^' + selText + '$';
  191. document.getElementById('opRSElevation').value = RSelExprParser._getSelectionIndex(document.getElementById('opRSElevation').options, selText);
  192. },
  193. val: function(selText) {
  194. selText = '^' + selText + '$';
  195. document.getElementById('selRSElevation').value = RSelExprParser._getSelectionIndex(document.getElementById('selRSElevation').options, selText);
  196. },
  197. add: function() {
  198. document.getElementById('btnRSAddElevation').click();
  199. }
  200. },
  201. manlock: {
  202. op: function(selText) {
  203. selText = '^' + selText + '$';
  204. document.getElementById('opRSManLock').value = RSelExprParser._getSelectionIndex(document.getElementById('opRSManLock').options, selText);
  205. },
  206. val: function(val) {
  207. document.getElementById('selRSManLock').value = val;
  208. },
  209. add: function() {
  210. document.getElementById('btnRSAddManLock').click();
  211. }
  212. },
  213. traflock: {
  214. op: function(selText) {
  215. selText = '^' + selText + '$';
  216. document.getElementById('opRSTrLock').value = RSelExprParser._getSelectionIndex(document.getElementById('opRSTrLock').options, selText);
  217. },
  218. val: function(val) {
  219. document.getElementById('selRSTrLock').value = val;
  220. },
  221. add: function() {
  222. document.getElementById('btnRSAddTrLock').click();
  223. }
  224. },
  225. speed: {
  226. opOptNodes: function() { return document.getElementById('opRSSpeed').options },
  227. op: function(selText) {
  228. selText = '^' + selText + '$';
  229. document.getElementById('opRSSpeed').value = RSelExprParser._getSelectionIndex(document.getElementById('opRSSpeed').options, selText);
  230. },
  231. val: function(val) {
  232. document.getElementById('inRSSpeed').value = val;
  233. },
  234. add: function() {
  235. document.getElementById('btnRSAddSpeed').click();
  236. }
  237. },
  238. closure: {
  239. op: function(checked) {
  240. document.getElementById('cbRSClsr').checked = checked;
  241. },
  242. op2: function(selText) {
  243. selText = '^' + selText + '$';
  244. document.getElementById('opRSClsrStrtEnd').value = RSelExprParser._getSelectionIndex(document.getElementById('opRSClsrStrtEnd').options, selText);
  245. },
  246. val: function(val) {
  247. document.getElementById('inRSClsrDays').value = val;
  248. },
  249. condmod: function(selText) {
  250. selText = '^' + selText + '$';
  251. document.getElementById('opRSClsrBeforeAter').value = RSelExprParser._getSelectionIndex(document.getElementById('opRSClsrBeforeAter').options, selText);
  252. },
  253. add: function() {
  254. document.getElementById('btnRSAddClsr').click();
  255. }
  256. },
  257. updatedby: {
  258. op: function(selText) {
  259. selText = '^' + selText + '$';
  260. document.getElementById('opRSUpdtd').value = RSelExprParser._getSelectionIndex(document.getElementById('opRSUpdtd').options, selText);
  261. },
  262. val: function(val) {
  263. document.getElementById('inRSUpdtd').value = val;
  264. },
  265. add: function() {
  266. document.getElementById('btnRSAddUpdtd').click();
  267. }
  268. },
  269. createdby: {
  270. op: function(selText) {
  271. selText = '^' + selText + '$';
  272. document.getElementById('opRSCrtd').value = RSelExprParser._getSelectionIndex(document.getElementById('opRSCrtd').options, selText);
  273. },
  274. val: function(val) {
  275. document.getElementById('inRSCrtd').value = val;
  276. },
  277. add: function() {
  278. document.getElementById('btnRSAddCrtd').click();
  279. }
  280. },
  281. last: {
  282. op: function(selText) {
  283. selText = '^' + selText + '$';
  284. document.getElementById('opRSLastU').value = RSelExprParser._getSelectionIndex(document.getElementById('opRSLastU').options, selText);
  285. },
  286. val: function(val) {
  287. document.getElementById('inRSLastU').value = val;
  288. },
  289. add: function() {
  290. document.getElementById('btnRSAddLastU').click();
  291. }
  292. },
  293. length: {
  294. op: function(selText) {
  295. selText = '^' + selText + '$';
  296. document.getElementById('opRSLength').value = RSelExprParser._getSelectionIndex(document.getElementById('opRSLength').options, selText);
  297. },
  298. val: function(val) {
  299. document.getElementById('inRSLength').value = val;
  300. },
  301. condmod: function(selText) {
  302. selText = '^' + selText + '$';
  303. document.getElementById('unitRSLength').value = RSelExprParser._getSelectionIndex(document.getElementById('unitRSLength').options, selText);
  304. },
  305. add: function() {
  306. document.getElementById('btnRSAddLength').click();
  307. }
  308. },
  309. id: {
  310. op: function(selText) {
  311. selText = '^' + selText + '$';
  312. document.getElementById('opRSSegId').value = RSelExprParser._getSelectionIndex(document.getElementById('opRSSegId').options, selText);
  313. },
  314. val: function(val) {
  315. document.getElementById('inRSSegId').value = val;
  316. },
  317. add: function() {
  318. document.getElementById('btnRSAddSegId').click();
  319. }
  320. },
  321. roundabout: {
  322. op: function(checked) {
  323. document.getElementById('cbRSIsRound').checked = checked;
  324. },
  325. add: function() {
  326. document.getElementById('btnRSAddIsRound').click();
  327. }
  328. },
  329. toll: {
  330. op: function(checked) {
  331. document.getElementById('cbRSIsToll').checked = checked;
  332. },
  333. add: function() {
  334. document.getElementById('btnRSAddIsToll').click();
  335. }
  336. },
  337. tunnel: {
  338. op: function(checked) {
  339. document.getElementById('cbRSTunnel').checked = checked;
  340. },
  341. add: function() {
  342. document.getElementById('btnRSAddTunnel').click();
  343. }
  344. },
  345. new: {
  346. op: function(checked) {
  347. document.getElementById('cbRSIsNew').checked = checked;
  348. },
  349. add: function() {
  350. document.getElementById('btnRSAddIsNew').click();
  351. }
  352. },
  353. changed: {
  354. op: function(checked) {
  355. document.getElementById('cbRSIsChngd').checked = checked;
  356. },
  357. add: function() {
  358. document.getElementById('btnRSAddIsChngd').click();
  359. }
  360. },
  361. screen: {
  362. op: function(checked) {
  363. document.getElementById('cbRSOnScr').checked = checked;
  364. },
  365. add: function() {
  366. document.getElementById('btnRSAddOnScr').click();
  367. }
  368. },
  369. restriction: {
  370. op: function(checked) {
  371. document.getElementById('cbRSRestr').checked = checked;
  372. },
  373. add: function() {
  374. document.getElementById('btnRSAddRestr').click();
  375. }
  376. },
  377. editable: {
  378. op: function(checked) {
  379. document.getElementById('cbRSEdtbl').checked = checked;
  380. },
  381. add: function() {
  382. document.getElementById('btnRSAddEdtbl').click();
  383. }
  384. }
  385. },
  386. addExpr: function(eb) {
  387. var checkKeys = false;
  388. Object.keys(this.rselConditions).map(function(a, i) {
  389. if (a === eb.cond)
  390. checkKeys = true;
  391. });
  392. if (checkKeys) {
  393. try {
  394. this.rselConditions[eb.cond].op(eb.op);
  395. if (eb.op2 !== null )
  396. this.rselConditions[eb.cond].op2(eb.op2);
  397. if (eb.condmod !== null )
  398. this.rselConditions[eb.cond].condmod(eb.condmod);
  399.  
  400. if (eb.val2 === null ) {
  401. if (eb.val !== null )
  402. this.rselConditions[eb.cond].val(eb.val);
  403. this.rselConditions[eb.cond].add();
  404. } else {
  405. this.rselButtons.lfParens();
  406. this.rselConditions[eb.cond].val(eb.val);
  407. this.rselConditions[eb.cond].add();
  408. this.rselButtons.or();
  409. this.rselConditions[eb.cond].val(eb.val2);
  410. this.rselConditions[eb.cond].add();
  411. this.rselButtons.rtParens();
  412. }
  413.  
  414. } catch (err) {
  415. return {
  416. errorCode: 101,
  417. errorMsg: 'Error: Unable to parse expression text.',
  418. err: err
  419. };
  420. }
  421. } else {
  422. return {
  423. errorCode: 3,
  424. errorMsg: 'Selection condition was not recognized'
  425. };
  426. //
  427. }
  428. return {
  429. errorCode: 0
  430. };
  431. },
  432. //=============================================================================
  433. parseExpr: function(parseThis) {
  434. //---------------------------------------------------------------
  435. parseThis = parseThis.replace(/\bpri?m?(?:ary|\.)?\s?(?:or)\s?alt(?:ern|s)?(?:\.)?/ig, 'any');
  436. parseThis = parseThis.replace(/\b((?:un)?name[ds]?)\b|\b(road) type\b|\b(last) update\b|\b(speed) limits?\b/ig, '$1$2$3$4')
  437. parseThis = parseThis.replace(/\b(man)ual (lock)s?\b|\b(traf)[fic]* (lock)s?\b/ig, '$1$2$3$4');
  438. parseThis = parseThis.replace(/\b(created|updated)\s(by)\b/ig, '$1$2');
  439. parseThis = parseThis.replace(/\bon screen/ig, 'onscreen');
  440. //\b(?:in|on|off|out|outside)(?: of)?[- ]?screen\b
  441. parseThis = parseThis.replace(/\b(?:off|out)(?: of)?[- ]?screen/ig, 'offscreen');
  442.  
  443. var parseExprArray = parseThis.match(
  444. /(\(['"].*?['"]\)|".*?"|'.*?'|\/.+?\/)|\bno[\s-]alt|\b(?:street[\s-]?)?name\(s\)|\bstreet(?:\snames?)\b|\btoll(?:[-\s]?ro?a?d)?\b|\bdoes(?:\s?n[o']t)\b|(?:!\s?)?contains?\b|\w+n't\b|!=|>=|<=|([ab](<-|->)[ab])|&&|\|\||!=|[|&<>=()!~]|[\u0023-\u0027\u002A-\u005A\u0061-\u007A\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]+/gim),
  445. parseExprHistory = [],
  446. condMatches = [],
  447. condMatchPhrases = [],
  448. exprMatches = [],
  449. exprMatchPhrases = [],
  450. exprFragment, unwantedWordsSearch,
  451. e, f, b, fLength;
  452.  
  453. // The following parses the expression text into unique chunks within separate array elements
  454. e = parseExprArray.length;
  455. while (e-- > 0) {
  456. try {
  457. exprFragment = parseExprArray.shift();
  458. //console.info(exprFragment);
  459.  
  460. // Find operators that join individual expressions (AND|OR|!|parenthesis)
  461. if (/^(?:and|or|&&|\|\||!=|[=&|()!])$/i.test(exprFragment)) {
  462. exprMatches.push(exprFragment.toLowerCase());
  463. exprMatchPhrases.push(exprFragment.toLowerCase());
  464. }
  465.  
  466. // Identify elements that contain selection condition names
  467. if (
  468. /^country|^state|^city|^street|^(?:un|street[\s-]?)?name|^road|^round|^toll|^speed|^dir|^elevation|^tun|^manlock|^traflock|^speed|^new|^changed|screen$|^restrict|^clos|^createdby|^last|^updatedby|^length|^id|^editable/i
  469. .test(exprFragment)) {
  470. condMatches.push(exprFragment.toLowerCase());
  471. // lists specific selection conditions
  472. exprMatches.push(exprFragment.toLowerCase());
  473. //same as condMatches, but includes operations as separate array elements
  474.  
  475. try {
  476. //search phrase fowards
  477. fLength = parseExprArray.length;
  478. f = 0;
  479. while (!(/^(and|or|&&|\|\||[&|)])$/i.test(parseExprArray[f])) && (++f < fLength)) {}
  480. //search phrase backwards
  481. b = parseExprHistory.length;
  482. while (!(/^(and|or|&&|\|\||[&|(])$/i.test(parseExprHistory[b - 1])) && (--b > 0)) {}
  483.  
  484. condMatchPhrases.push(parseExprHistory.slice(b).concat(exprFragment, parseExprArray.slice(0, f)));
  485. //list specific selection conditions and its criteria
  486.  
  487. unwantedWordsSearch = parseExprHistory.slice(b);
  488. if (unwantedWordsSearch && unwantedWordsSearch.length) {
  489. unwantedWordsSearch = unwantedWordsSearch.filter(function(a) {
  490. return !/\b(has|have|is|=|are|does|was|were)\b/i.test(a)
  491. });
  492. }
  493. if (/!|!=/.test(unwantedWordsSearch[0]))
  494. unwantedWordsSearch.splice(0, 1);
  495.  
  496. exprMatchPhrases.push(unwantedWordsSearch.concat(parseExprArray.slice(0, f)));
  497. //excludes the match cond
  498.  
  499. parseExprHistory = parseExprHistory.concat(exprFragment, parseExprArray.slice(0, f));
  500. parseExprArray = parseExprArray.slice(f);
  501. e -= f;
  502. } catch (err) {
  503. return {
  504. errorCode: 101,
  505. errorMsg: 'Error parsing expression at ' + exprFragment,
  506. err: err
  507. };
  508. }
  509. } else {
  510. parseExprHistory.push(exprFragment);
  511. }
  512. } catch (err) {
  513. return {
  514. errorCode: 101,
  515. errdebug: 'Error parsing expression at ' + exprFragment,
  516. err: err
  517. };
  518. }
  519. }
  520. //while
  521.  
  522.  
  523. //---------------------------------------------------------------
  524. // Quick crude check for unmatched parentheses
  525. var nOpenParens = exprMatches.toString().match(/\(/g),
  526. nCloseParens = exprMatches.toString().match(/\)/g);
  527. if (!nOpenParens) nOpenParens = [];
  528. if (!nCloseParens) nCloseParens = [];
  529. if (nOpenParens.length !== nCloseParens.length)
  530. return {
  531. errorCode: 1,
  532. errorMsg: 'Warning: Open and close paretheses may be unmatched.'
  533. };
  534.  
  535. //---------------------------------------------------------------
  536.  
  537. return {
  538. errorCode: 0,
  539. exprMatches: exprMatches,
  540. exprMatchPhrases: exprMatchPhrases,
  541. condMatches: condMatches,
  542. condMatchPhrases: condMatchPhrases
  543. };
  544. },
  545. buildExpr: function(exprWord, exprPhrase) {
  546.  
  547. var exprBuild = RSelExprParser._getNewExprBuild();
  548. exprBuild.cond = exprWord;
  549.  
  550. //if (m===10) debugger;
  551.  
  552. //============================================================
  553. // Where the magic happens... sort of.
  554. //============================================================
  555. switch (true) {
  556. case exprWord === '(':
  557. this.rselButtons.lfParens();
  558. return false;
  559. case exprWord === ')':
  560. this.rselButtons.rtParens();
  561. return false;
  562. case 'and' === exprWord:
  563. this.rselButtons.and();
  564. return false;
  565. case 'or' === exprWord:
  566. this.rselButtons.or();
  567. return false;
  568. case /no alt/i.test(exprPhrase):
  569. exprBuild.cond = 'unnamed';
  570. exprBuild.op = true;
  571. exprBuild.op2 = true;
  572. return exprBuild;
  573. case '!' === exprWord:
  574. this.rselButtons.not();
  575. return false;
  576. case /^unnamed/.test(exprBuild.cond):
  577. exprBuild.cond = 'unnamed';
  578. exprBuild.op = true;
  579. exprBuild.op2 = false;
  580. return exprBuild;
  581.  
  582. // SPEED LIMITS
  583. case 'speed' === exprBuild.cond:
  584. try {
  585. if (exprPhrase.length < 2 && /\bnot?\b|!|!=/i.test(exprPhrase[0])) {
  586. exprBuild.op = 'none';
  587. } else {
  588. exprPhrase = exprPhrase.join(' ');
  589.  
  590. if (/\bnot?\b|!|!=/i.test(exprPhrase)) {
  591. RSelExprParser.rselButtons.not();
  592. }
  593.  
  594. var optionText = RSelExprParser._getSelectOptions(RSelExprParser.rselConditions.speed.opOptNodes());
  595. optionText = RegExp(optionText.join('|'), 'i').exec(exprPhrase);
  596. if (optionText) exprBuild.op = optionText[0];
  597. else exprBuild.op = 'any';
  598. }
  599.  
  600. if (exprPhrase.length > 1) {
  601. exprBuild.val = exprPhrase.replace(/.*?(\d+)\s?mph.*|.*?(\d+)\s?km.*/i,'$1$2');
  602. } else {
  603. exprBuild.val = '';
  604. }
  605. } catch (err) {
  606. exprBuild.errorCode = 101;
  607. exprBuild.err = err;
  608. return exprBuild;
  609. }
  610. return exprBuild;
  611.  
  612. // BINARY CONDITIONS:
  613. case exprPhrase.length === 0 || //suggests binary
  614. /^(screen|roundabout|toll|tun|new|changed|restrict|editable)/.test(exprBuild.cond) || //binary selection conditions
  615. (/^name.*|^closure/i.test(exprBuild.cond) && exprPhrase.length <= 1):
  616. //selection conditions that have both binary and multiple options
  617.  
  618. exprPhrase = exprPhrase.join(' ');
  619.  
  620. exprBuild.cond = exprBuild.cond.replace(/^name.*/, 'name');
  621. exprBuild.cond = exprBuild.cond.replace(/^toll\s.*/, 'toll');
  622.  
  623. if (/\bnot?\b|!|!=/i.test(exprPhrase)) {
  624. exprBuild.op = false;
  625. } else {
  626. exprBuild.op = true;
  627. }
  628. switch (exprBuild.cond) {
  629. case 'name':
  630. try {
  631. if (/alt/i.test(exprPhrase)) {
  632. exprBuild.cond = 'unnamed';
  633. exprBuild.op = false;
  634. exprBuild.op2 = true;
  635. } else {
  636. exprBuild.cond = 'unnamed';
  637. exprBuild.op = false;
  638. exprBuild.op2 = false;
  639. }
  640. return exprBuild;
  641. } catch (err) {
  642. exprBuild.errorCode = 101;
  643. exprBuild.err = err;
  644. return exprBuild;
  645. }
  646. case 'closure':
  647. exprBuild.op2 = '---';
  648. exprBuild.val = '';
  649. return exprBuild;
  650. case 'onscreen':
  651. exprBuild.cond = 'screen';
  652. exprBuild.op = true;
  653. return exprBuild;
  654. case 'offscreen':
  655. exprBuild.cond = 'screen';
  656. exprBuild.op = false;
  657. return exprBuild;
  658. case 'roundabout':
  659. case 'toll':
  660. case 'tunnel':
  661. case 'new':
  662. case 'changed':
  663. case 'restriction':
  664. case 'editable':
  665. return exprBuild;
  666. default:
  667. exprBuild.errorCode = 101;
  668. exprBuild.errorMsg = 'Error: Presumed binary selector had no match.';
  669. return exprBuild;
  670. }
  671. //switch
  672.  
  673. //--------------------------------------------------------------------
  674.  
  675. case /^closure/.test(exprBuild.cond):
  676. try {
  677. exprPhrase = exprPhrase.join().toLowerCase();
  678. exprBuild.op = !(/does\s?n['o]t|!|!=/.test(exprPhrase));
  679. //checkbox
  680. exprBuild.op2 = /start|end/.exec(exprPhrase) + 's';
  681. //starts/ends
  682. exprBuild.condmod = /before|after|\bin\b/.exec(exprPhrase) + '';
  683. //in/before/after
  684. if (!exprBuild.condmod)
  685. exprBuild.condmod = 'in';
  686. exprBuild.val = /\d+/.exec(exprPhrase) + '';
  687. //days ago
  688. } catch (err) {
  689. exprBuild.errorCode = 101;
  690. exprBuild.err = err;
  691. return exprBuild;
  692. }
  693. return exprBuild;
  694.  
  695. default:
  696. // CONDITION NAME MATCHING (TYPE OF SELECTION)
  697. try {
  698. if (/^(str.*|cit.*)/.test(exprBuild.cond)) {
  699. exprBuild.cond = exprBuild.cond.replace(/^str.*/, 'street');
  700. exprBuild.cond = exprBuild.cond.replace(/^cit.*/, 'city');
  701. var exprStart = exprPhrase.slice(0, -1), //don't include last element bc it should be the name itself
  702. prim, alt;
  703. if (exprStart) {
  704. //exprStart = exprStart.toString().toLowerCase();
  705. prim = /\bprim?(?:ary|\.)?\b/i.test(exprStart);
  706. alt = /\balt(?:ern\w*|\.)?\b/i.test(exprStart);
  707. any = /\bany\b/i.test(exprStart);
  708. exprPhrase = exprStart.filter(function(a) {return !/^pr|^alt|^any/i.test(a)}).concat(exprPhrase.slice(-1));
  709. } else {
  710. prim = false;
  711. alt = false;
  712. }
  713. if ((prim && alt) || any)
  714. exprBuild.condmod = 2;
  715. else if (prim)
  716. exprBuild.condmod = 0;
  717. else if (alt)
  718. exprBuild.condmod = 1;
  719. else
  720. exprBuild.condmod = 0;
  721. }
  722. } catch (err) {
  723. exprBuild.errorCode = 101;
  724. exprBuild.err = err;
  725. return exprBuild;
  726. }
  727.  
  728. // COMPARATOR OPERATION MATCHING
  729. try {
  730. // Convert to standard comparator operations
  731. var exprPhraseStr = exprPhrase.join(' ').replace(/\bcontains?/i, 'contains').replace(/(?:\bdo(?:es)?\s?n[o']t\s|!\s?)(contains)/i, '! $1');
  732. //.replace(/\b(?:do(?:es)?\s?n[o']t\s|!\s?)contains?/i, '!^').replace(/\bcontains?/i,'\u220b');
  733.  
  734. // Comparator operations with standard representation
  735. exprBuild.op = /(?:! )?contains|[!<>=~]{1,2}/i.exec(exprPhraseStr) + '';
  736.  
  737. } catch (err) {
  738. exprBuild.errorCode = 101;
  739. exprBuild.err = err;
  740. return exprBuild;
  741. }
  742.  
  743. // SELECTION VALUE MATCHING
  744. if (/^length|^last/.test(exprBuild.cond)) {
  745. exprBuild.val = exprPhraseStr.match(/\b\d+/) + '';
  746. } else {
  747. try {
  748. var blackmagic = '[\u0023-\u005A\u0061-\u007A\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]+',
  749. whitemagic = '^\\(["\'](.*?)[\'"]\\)$|^\\s?["\'](.*)["\']$|^["\'](.*)[\'"]$|\\b(';
  750.  
  751. // The following line is kind of elaborate bc it needed to grab text between parens/quotes while keeping the inner quotes
  752. exprBuild.val = exprPhraseStr.replace(new RegExp('^(?:\\s?' + exprBuild.op + '\\s)(.*)','i'),'$1').replace(new RegExp(whitemagic + blackmagic + '?)\\b','ig'),'$1$2$3$4').replace(new RegExp('(") (' + blackmagic + ') (")','ig'),'$1$2$3');
  753.  
  754. if (!/^street|^city/.test(exprBuild.cond)) {
  755. exprBuild.val = exprBuild.val.replace(/"(.*)"|'(.*)'/, '$1$2');
  756. }
  757. } catch (err) {
  758. exprBuild.errorCode = 2;
  759. exprBuild.err = err;
  760. return exprBuild;
  761. }
  762.  
  763. if (/^direction/.test(exprBuild.cond)) {
  764. exprBuild.val = exprBuild.val.match(/A[<>-\s]*B|B[<>-\s]*A|^"?one[\s-]?ways?"?$|unknown|\btwo/i)+''; //reduce to unique key words... last option will automatically input both one ways
  765. //reduce to unique key words...
  766. }
  767. }
  768.  
  769. return exprBuild;
  770. }
  771. //switch
  772. },
  773. //parseExpr()
  774. updateExpression: function(parseThis) {
  775. this.rselButtons.clear();
  776. if (parseThis) {
  777. //console.info('*** Begin parsing expression... ***');
  778.  
  779.  
  780. var parsed = this.parseExpr(parseThis);
  781.  
  782. if (parsed && !parsed.errorCode) {
  783. var exprMatches = parsed.exprMatches,
  784. exprMatchPhrases = parsed.exprMatchPhrases,
  785. exprFragment, exprFragPhrase, mLength, m;
  786.  
  787. mLength = exprMatchPhrases.length;
  788. for (m = 0; m < mLength; m++) {
  789. RSelExprParser.__EXPR_DEBUGINFO = this.new__EXPR_DEBUGINFO(m, exprMatches[m], exprMatchPhrases[m]);
  790.  
  791. //if (m > 3) debugger;
  792.  
  793. exprFragment = exprMatches[m];
  794. exprFragPhrase = exprMatchPhrases[m];
  795.  
  796. if (exprFragPhrase.constructor !== Array) exprFragPhrase = [exprFragPhrase];
  797.  
  798. var exprBuild = this.buildExpr(exprFragment, exprFragPhrase);
  799.  
  800. if (exprBuild && !exprBuild.errorCode) {
  801. RSelExprParser.__EXPR_DEBUGINFO.errorStatus = this.addExpr(exprBuild);
  802.  
  803. if (RSelExprParser.__EXPR_DEBUGINFO.errorStatus && RSelExprParser.__EXPR_DEBUGINFO.errorStatus.errorCode) {
  804. console.warn('updateExpression() may have partly failed. Check results.');
  805. RSelExprParser.__EXPR_DEBUGINFO.exprBuild = exprBuild;
  806. console.debug(RSelExprParser.__EXPR_DEBUGINFO);
  807. return false;
  808. }
  809. } else if (exprBuild && exprBuild.errorCode) {
  810. console.warn('updateExpression() may have partly failed. Check results.');
  811. RSelExprParser.__EXPR_DEBUGINFO.exprBuild = exprBuild;
  812. console.debug(RSelExprParser.__EXPR_DEBUGINFO);
  813. return false;
  814. }
  815. } //for each condition matched
  816.  
  817. return this.getCurrentExprText();
  818. } else {
  819. console.debug(parsed);
  820. return false;
  821. }
  822. } else {
  823. return null;
  824. }
  825. }
  826. };