projects
/
Pman.Core
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
check what is being written to our log files.
[Pman.Core]
/
Pman.SearchTokenizer.js
diff --git
a/Pman.SearchTokenizer.js
b/Pman.SearchTokenizer.js
index
a55605d
..
8db0be1
100644
(file)
--- a/
Pman.SearchTokenizer.js
+++ b/
Pman.SearchTokenizer.js
@@
-14,8
+14,8
@@
Pman.SearchTokenizer = function(s)
{
Pman.SearchTokenizer = function(s)
{
- this.str =
s
;
- this.strlen =
s.length
;
+ this.str =
typeof(s) == 'string' ? s : ''
;
+ this.strlen =
typeof(s) == 'string' ? s.length : 0
;
this.i = 0;
this.tokens = [];
//print_r(this);
this.i = 0;
this.tokens = [];
//print_r(this);
@@
-49,15
+49,20
@@
Pman.SearchTokenizer.prototype = {
}
}
}
}
+ // sort tokens longest first..
+
+
+
// should not get here...
return this.tokens;
},
strParse : function ()
{
// should not get here...
return this.tokens;
},
strParse : function ()
{
-
- str = '';
+ var c;
+
var
str = '';
while(true) {
while(true) {
- if (false === (c = this.getChar())) {
+ c = this.getChar();
+ if (false === c) {
this.addStr(str);
return;
}
this.addStr(str);
return;
}
@@
-68,7
+73,7
@@
Pman.SearchTokenizer.prototype = {
case '(':
case ')': this.addStr(str); this.ungetChar(); return;
case '"':
case '(':
case ')': this.addStr(str); this.ungetChar(); return;
case '"':
- if (str
len(str)
) {
+ if (str
.length
) {
this.addStr(str);
str = '';
}
this.addStr(str);
str = '';
}
@@
-76,17
+81,20
@@
Pman.SearchTokenizer.prototype = {
break;
default :
break;
default :
- str
.
= c;
+ str
+
= c;
continue;
}
}
continue;
}
}
- }
- function strParseQuoted(end)
+ },
+
+ strParseQuoted: function (end)
{
{
- str = ''; /// ignore \" slashed ???
+ var str = ''; /// ignore \" slashed ???
+ var c;
while(true) {
while(true) {
- if (false === (c = this.getChar())) {
+ c = this.getChar();
+ if (false === c) {
this.addStr(str,true);
return;
}
this.addStr(str,true);
return;
}
@@
-94,40
+102,46
@@
Pman.SearchTokenizer.prototype = {
this.addStr(str,true);
return;
}
this.addStr(str,true);
return;
}
- str
.
= c;
+ str
+
= c;
}
}
- }
- function addStr(s, q=false) { //q == quoted..
- s = q ? s : trim(s);
- if (!strlen(s)) {
+ },
+ addStr : function (s,q) { //q == quoted..
+ q = q || false;
+
+ s = q ? s : Roo.util.Format.trim(s);
+ if (!s.length) {
return;
}
return;
}
+
if (!q) {
if (!q) {
-
- if ((strtoupper(s) == 'AND') || (strtoupper(s) == 'OR')) {
- this.tokens[] = new Text_SearchParser_Token_Op(strtoupper(s));
+ if ((s.toUpperCase() == 'AND') || (s.toUpperCase() == 'OR')) {
+ this.tokens.push( { type: s.toUpperCase() });
return;
}
}
return;
}
}
- this.tokens
[] = new Text_SearchParser_Token_String(s
);
- }
+ this.tokens
.push( { type : 's' , v : s, q: q }
);
+ }
,
-
function getChar
()
+
getChar : function
()
{
{
+
if (this.i >= this.strlen) {
return false;
}
c = this.str[this.i];
this.i++;
return c;
if (this.i >= this.strlen) {
return false;
}
c = this.str[this.i];
this.i++;
return c;
- }
-
function ungetChar
()
+ }
,
+
ungetChar : function
()
{
this.i--;
}
{
this.i--;
}
-
-
-
+
+};
+
+Pman.SearchTokenizer.parse = function(v) {
+ var x = new Pman.SearchTokenizer(v);
+ return x.parse();
}
\ No newline at end of file
}
\ No newline at end of file