| 20 | } |
| 21 | |
| 22 | function matchQuery(all, query) { |
| 23 | var node = { query: query } |
| 24 | if (query.indexOf('not ') === 0) { |
| 25 | node.not = true |
| 26 | query = query.slice(4) |
| 27 | } |
| 28 | |
| 29 | for (var name in all) { |
| 30 | var type = all[name] |
| 31 | var match = query.match(type.regexp) |
| 32 | if (match) { |
| 33 | node.type = name |
| 34 | for (var i = 0; i < type.matches.length; i++) { |
| 35 | node[type.matches[i]] = match[i + 1] |
| 36 | } |
| 37 | return node |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | node.type = 'unknown' |
| 42 | return node |
| 43 | } |
| 44 | |
| 45 | function pushClause(all, qs, text, compose) { |
| 46 | var node = matchQuery(all, text.trim()) |