This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getLiteralStrings = function (queryString) { | |
// this function steps through the input string, recognizes literal strings, | |
// remembers their position in the input string and returns an array that | |
// contains objects like this: | |
// {startPoint: n, endPoint: m, sequenceOfCharacters: s} | |
var currentlyInString = false; | |
var delimeterOfCurrentString = ""; | |
var numberOfCurrentString = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
parseQuery = function (queryString) { | |
var literalStrings = getLiteralStrings(queryString); | |
var strippedString = stripLiteralStrings(queryString, literalStrings); | |
var booleanExpression = getBooleanExpression(strippedString); | |
var strippedComparisons = getStrippedComparisons(strippedString); | |
var comparisons = constructComparisons(strippedComparisons, literalStrings); | |
return { booleanExpression: booleanExpression, | |
comparisons: comparisons |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
parseQuery = function (queryString) { | |
var literalStrings = getLiteralStrings(queryString); | |
var strippedString = stripLiteralStrings(queryString, literalStrings); | |
var booleanExpression = getBooleanExpression(strippedString); | |
var strippedComparisons = getStrippedComparisons(strippedString); | |
var comparisons = constructComparisons(strippedComparisons, literalStrings); | |
return { booleanExpression: booleanExpression, | |
comparisons: strippedComparisons //temporary, will be comparisons then finished |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var queryGrammar = { | |
'UNKNOWN' : { | |
firstCharacter : /\S/, | |
notAllowed : /[\s'"\w\d\(\)]/, | |
reserved : { | |
'WILD_CARD' : ['@%'], | |
'COMPARATOR' : ['=','!=','<','<=','>','>='] | |
}}, | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var buildTokenTree = function (tokenList) { | |
//var tokenList = tokenList; | |
var openParenthesisStack = []; | |
var booleanOperatorStack = []; | |
//var currentToken = null; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Copy this code into the console and execute t=tree(q) for a start | |
Check the tree t with t[0].leftSide, t[0].rightSide.leftSide and so on... | |
Known problems: | |
-Tokenizer doesn't recognise tokens of lengh 1 at the end of the query string | |
-Boolean NOT doesn't work | |
-All logic patterns are still only in general binary form | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this one works, calling Obj1.f(1) gives [1,3,5,7,9] | |
Obj1 = { | |
n: 10, | |
s: [], | |
f: function(m){ | |
if(m<=this.n){ | |
this.s.push(m); | |
this.g.g1(m+1); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this one works, calling Obj1.f(1) gives [1,3,5,7,9] | |
Obj1 = { | |
n: 10, | |
s: [], | |
f: function(m){ | |
if(m<=this.n){ | |
this.s.push(m); | |
this.g.g1(m+1); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Copy this code into the console and execute Query.analyzeQuery(q1) for a start. | |
Check the Query object for its properties... | |
If an error occured while parsing, Query.tokenTree.error will give an explanation. | |
Execute Query.recordMatchesQuery(r1) to see validation of example record. | |
Execute Query.analyzeQuery(q2) followed by |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Copy this code into the console and execute Query.analyze(q1) for a start. | |
Check the Query object for its properties... | |
If an error occured while parsing, Query.tokenTree.error will give an explanation. | |
Execute Query.recordMatches(r1) to see validation of example record. | |
Execute Query.analyze(q2) followed by |
OlderNewer