| 42 | } |
| 43 | |
| 44 | function matchQuery(all, query) { |
| 45 | var node = { query: query } |
| 46 | var not = query.match(/^not\s+(?!\s)/i) |
| 47 | if (not) { |
| 48 | node.not = true |
| 49 | query = query.slice(not[0].length) |
| 50 | } |
| 51 | |
| 52 | for (var name in all) { |
| 53 | var type = all[name] |
| 54 | var match = query.match(type.regexp) |
| 55 | if (match) { |
| 56 | node.type = name |
| 57 | for (var i = 0; i < type.matches.length; i++) { |
| 58 | node[type.matches[i]] = match[i + 1] |
| 59 | } |
| 60 | return node |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | node.type = 'unknown' |
| 65 | return node |
| 66 | } |
| 67 | |
| 68 | function pushClause(all, qs, text, compose) { |
| 69 | var node = matchQuery(all, text.trim()) |